var __defProp = Object.defineProperty,
	__defNormalProp = (e, t, s) => (t in e ? __defProp(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : (e[t] = s)),
	__publicField = (e, t, s) => (__defNormalProp(e, 'symbol' != typeof t ? t + '' : t, s), s);
!(function (e, t) {
	'object' == typeof exports && 'undefined' != typeof module
		? t(exports)
		: 'function' == typeof define && define.amd
			? define(['exports'], t)
			: t(((e = 'undefined' != typeof globalThis ? globalThis : e || self).WSPlayer = {}));
})(this, function (e) {
	'use strict';
	const t = {
			websocketPorts: {
				realmonitor: 'realmonitor-websocket',
				playback: 'playback-websocket',
				realmonitor_ws: '9100',
				playback_ws: '9320',
				realmonitor_wss: '9102',
				playback_wss: '9322',
			},
			errorVideoInfo: {
				101: '播放延时大于8s',
				201: '当前音频无法播放',
				202: 'websocket连接错误',
				203: '文件播放完成',
				401: '该用户无操作权限',
				404: '请求超时或未找到',
				405: '播放超时',
				406: '视频流类型解析失败，请检查通道配置',
				407: '请求超时',
				408: '请求超时或码流不支持',
				409: '请求超时或码流不支持',
				410: '视频流异常断开',
				411: '录像播放完成',
				457: '时间设置错误',
				503: 'WS连接地址错误，非当前连接的ICC服务器返回',
				504: '对讲失败',
				701: 'Chrome版本低，请升级到最新的Chrome版本',
				702: 'Firefox版本低，请升级到最新的Firefox版本',
				703: 'Edge版本低，请升级到最新的Edge版本',
				defaultErrorMsg: '播放失败，请检查配置',
			},
			errorInfo: {
				101: '所选通道离线，无法播放',
				102: '登录权限过期，查询实时预览rtsp失败',
				103: '接口未通，请检查项目后端是否未转发接口。',
				201: '所选通道未查询到录像文件',
				202: '查询录像文件列表失败',
				203: '查询录像rtsp失败',
				204: '$0倍速无法播放音频',
				301: '正在对讲，无法关闭音频',
				302: '其他设备对讲中，无法开启音频',
				303: '其他设备对讲中，无法开启对讲',
				304: '查询对讲rtsp失败',
				305: 'http协议不支持对讲',
				306: '设备对讲失败',
				307: '不支持PCM音频格式对讲',
				308: '不支持ARM音频格式对讲',
				309: '不支持G711u音频格式对讲',
				310: '不支持G726音频格式对讲',
				311: '不支持AAC音频格式对讲',
				312: '不支持G722音频格式对讲',
				501: '解码库未初始化完成，请稍后播放！',
				502: '解码库未初始化完成，请稍后对讲！',
				503: '请检查创建播放器时，播放器容器是否存在',
				601: '所操作播放器不存在',
				602: '所选播放器正在本地录像中，不可重复本地录像',
				603: '所选播放器未播放录像，不可本地录像',
				604: '所选播放器未开始本地录像，不可操作关闭本地录像',
				605: '时间跳转播放传参错误',
				606: '设置自适应拉伸传参错误',
				607: '实时预览不支持倍速播放',
				608: '需传入正确的$0方法：$1',
				610: '操作自定义窗口布局失败：$0',
				611: '实时预览不支持播放方法',
				612: '实时预览不支持暂停方法',
				613: '实时预览不支持跳转播放',
				701: '云台被用户$0锁定，无法操作',
				702: '控制云台三维定位失败$0',
				703: '控制云台$0$1失败$2',
				704: '控制云台方向失败$0',
			},
			windowDefaultCustomDivision: {
				2: [
					{ lStep: 0, tStep: 0, wStep: 50, hStep: 100 },
					{ lStep: 50, tStep: 0, wStep: 50, hStep: 100 },
				],
				3: [
					{ wStep: 50, hStep: 100, tStep: 0, lStep: 0 },
					{ wStep: 50, hStep: 50, tStep: 0, lStep: 50 },
					{ wStep: 50, hStep: 50, tStep: 50, lStep: 50 },
				],
				6: [
					{ wStep: 66, hStep: 66, tStep: 0, lStep: 0, selectIndex: 0 },
					{ wStep: 34, hStep: 33, tStep: 0, lStep: 66, selectIndex: 1 },
					{ wStep: 34, hStep: 33, tStep: 33, lStep: 66, selectIndex: 2 },
					{ wStep: 33, hStep: 34, tStep: 66, lStep: 0, selectIndex: 3 },
					{ wStep: 33, hStep: 34, tStep: 66, lStep: 33, selectIndex: 4 },
					{ wStep: 34, hStep: 34, tStep: 66, lStep: 66, selectIndex: 5 },
				],
				8: [
					{ wStep: 75, hStep: 75, tStep: 0, lStep: 0, selectIndex: 0 },
					{ wStep: 25, hStep: 25, tStep: 0, lStep: 75, selectIndex: 1 },
					{ wStep: 25, hStep: 25, tStep: 25, lStep: 75, selectIndex: 2 },
					{ wStep: 25, hStep: 25, tStep: 50, lStep: 75, selectIndex: 3 },
					{ wStep: 25, hStep: 25, tStep: 75, lStep: 0, selectIndex: 4 },
					{ wStep: 25, hStep: 25, tStep: 75, lStep: 25, selectIndex: 5 },
					{ wStep: 25, hStep: 25, tStep: 75, lStep: 50, selectIndex: 6 },
					{ wStep: 25, hStep: 25, tStep: 75, lStep: 75, selectIndex: 7 },
				],
			},
			iconConfig: [
				{ key: 'talkIcon', label: '对讲', buttonParentClass: 'ws-talk', buttonIconClass: 'opt-icon talk-icon off' },
				{ key: 'localRecordIcon', label: '录像', buttonParentClass: 'ws-record', buttonIconClass: 'opt-icon record-icon' },
				{ key: 'audioIcon', label: '声音', buttonParentClass: 'ws-audio', buttonIconClass: 'opt-icon audio-icon off' },
				{ key: 'snapshotIcon', label: '抓图', buttonParentClass: 'ws-capture', buttonIconClass: 'opt-icon capture-icon' },
			],
		},
		s = { Opera: 'Opera', Chrome: 'Chrome', Firefox: 'Firefox', Edge: 'Edge', Edg: 'Edg', IE: 'IE', Safari: 'Safari' };
	const i = {
		checkBrowser: function () {
			const e = (function () {
					const { userAgent: e } = navigator;
					return e.includes('Edge')
						? s.Edge
						: e.includes('Edg')
							? s.Edg
							: e.includes('Firefox')
								? s.Firefox
								: e.includes('Chrome')
									? s.Chrome
									: e.includes('Safari')
										? s.Safari
										: e.includes('compatible') && e.includes('MSIE') && e.includes('Opera')
											? s.IE
											: e.includes('Opera')
												? s.Opera
												: '';
				})(),
				t = navigator.userAgent.includes('x64') || navigator.userAgent.includes('x86_64') ? 64 : 32,
				i = (function (e) {
					const { userAgent: t } = navigator;
					return t.split(e)[1].split('.')[0].slice(1);
				})(e);
			let a = !1,
				l = 0;
			switch (e) {
				case s.Chrome:
					(a = i >= 91 && 64 === t), (l = 701);
					break;
				case s.Firefox:
					(a = i >= 97), (l = 702);
					break;
				case s.Edge:
				case s.Edg:
					(a = i >= 91), (l = 703);
					break;
				default:
					a = 0;
			}
			return { isVersionCompliance: a, browserType: e, errorCode: l };
		},
		validFunction: function (e) {
			return '[object Function]' === toString.call(e);
		},
		mergeObject: function e() {
			let t = {};
			for (let i = 0; i < arguments.length; i++) {
				let a = arguments[i];
				for (let i in a) {
					let l = a[i];
					(s = l), '[object Object]' === toString.call(s) ? (t[i] = e(l)) : (t[i] = l);
				}
			}
			var s;
			return t;
		},
		getDateFormatByUnderline: function () {
			return (function () {
				let e = new Date();
				return [e.getFullYear(), e.getMonth() + 1, e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds()];
			})().join('_');
		},
		throttle: function (e, t) {
			let s;
			return function () {
				s ||
					(e.apply(this, arguments),
					(s = setTimeout(() => {
						s = 0;
					}, t)));
			};
		},
		debounce: function (e, t) {
			let s;
			return function () {
				s && clearTimeout(s),
					(s = setTimeout(() => {
						e.apply(this, arguments), (s = 0);
					}, t));
			};
		},
	};
	class a {
		constructor(e) {
			(this.$el = null),
				(this.canvasElem = null),
				(this.videoElem = null),
				(this.wrapperDomId = e.wrapperDomId),
				(this.domId = e.wrapperDomId + '-' + e.index),
				(this.wsPlayer = e.wsPlayer),
				(this.index = e.index),
				(this.initIndex = e.index),
				(this.firstTime = 0),
				(this.isAudioPlay = !1),
				(this.speed = 1);
		}
		initDom() {
			let e = this.getTemplate(),
				t = $(e);
			this.wsPlayer.$wrapper.append(t[0]),
				(this.$el = $('#' + this.domId)),
				(this.canvasElem = document.getElementById(this.canvasId) || {}),
				(this.ivsCanvasElem = document.getElementById(this.ivsCanvasId) || {}),
				(this.pztCanvasElem = document.getElementById(this.pztCanvasId) || {}),
				(this.videoElem = document.getElementById(this.videoId)),
				(this.showIcons = this.wsPlayer.config.showIcons || {}),
				(this.showIconNum = 5),
				this.showIcons.streamChangeSelect || this.setDomHiddenDeep($('.select-container', this.$el), !1),
				this.setTalkIconShow(),
				this.showIcons.audioIcon || (this.setDomHiddenDeep($('.ws-audio', this.$el), !1), this.showIconNum--),
				this.showIcons.snapshotIcon || (this.setDomHiddenDeep($('.ws-capture', this.$el), !1), this.showIconNum--),
				this.showIcons.localRecordIcon || (this.setDomHiddenDeep($('.ws-record', this.$el), !1), this.showIconNum--),
				this.showIcons.closeIcon || (this.setDomHiddenDeep($('.ws-close', this.$el), !1), this.showIconNum--),
				(this.showMoreIcon = !1);
		}
		setTalkIconShow() {
			let { talkIcon: e } = this.wsPlayer.config.showIcons || {},
				t = location.protocol;
			e && 'https:' === t && 'real' === this.wsPlayer.type
				? $('.ws-talk', this.$el).css({ display: '' })
				: (this.setDomHiddenDeep($('.ws-talk', this.$el), !1), this.showIconNum--);
		}
		initMouseEvent() {
			this.$el.click((e) => {
				this.wsPlayer.setSelectIndex(this.index),
					this.$el.siblings().removeClass('selected').addClass('unselected'),
					this.$el.removeClass('unselected').addClass('selected');
			}),
				this.$el.dblclick((e) => {
					if (1 !== this.wsPlayer.options.config.maxNum) {
						if (1 !== this.wsPlayer.showNum) {
							this.wsPlayer.beforeShowNum = this.wsPlayer.showNum;
							let e = $(`#${this.wrapperDomId} .wsplayer-item`);
							this.wsPlayer.resetPlayerScreen(e, this.wsPlayer.options.config.maxNum),
								$(`#${this.wrapperDomId}-${this.index}`).css({ top: 0, left: 0, width: '100%', height: '100%', visibility: 'visible' }),
								(this.wsPlayer.showNum = 1);
						} else this.wsPlayer.setPlayerNum(this.wsPlayer.beforeShowNum, !0);
						this.wsPlayer.setSelectIndex(this.index),
							this.$el.siblings().removeClass('selected').addClass('unselected'),
							this.$el.removeClass('unselected').addClass('selected'),
							setTimeout(() => {
								this.wsPlayer.__updatePlayerWindow();
							}, 200);
					}
				}),
				$('.ws-audio', this.$el).click((e) => {
					if (this.wsPlayer.isTalking && this.isTalking && this.gbTalk) console.log('当前为国标对讲，不控制音量');
					else if (this.wsPlayer.isTalking) return void this.wsPlayer.sendErrorMessage(this.isTalking ? '301' : '302');
					if (this.isAudioPlay) this.closeVolume();
					else {
						if (this.playSDK.isPlayback && 1 !== Number(this.speed)) return void this.wsPlayer.sendErrorMessage('204', { insert: [this.speed] });
						this.openVolume();
					}
				});
			$('.ws-talk', this.$el).click(
				i.throttle((e) => {
					if ('http:' !== location.protocol)
						if (this.wsPlayer.isTalking && !this.isTalking) this.wsPlayer.sendErrorMessage('303');
						else if (this.isTalking) this.stopTalk();
						else {
							if ('url' === this.options.playType) {
								const { selectIndex: e, channelData: t } = this.options;
								return void this.wsPlayer.sendMessage('notifyTalk', { selectIndex: e, channelData: { ...t } });
							}
							this.resumeAudio(),
								this.setAuthority(
									{ channelCode: this.options.channelData ? this.options.channelData.channelCode : this.options.channelId, function: '3' },
									() => {
										(this.wsPlayer.talkIndex = this.index), this.wsPlayer.__startTalk(this.options.channelData);
									},
									(e) => {
										1103 === e.code && this.wsPlayer.sendErrorMessage(401, { type: 'talk' });
									}
								);
						}
					else this.wsPlayer.sendErrorMessage('305');
				}, 2e3)
			),
				$('.ws-capture', this.$el).click((e) => {
					this.setAuthority(
						{ channelCode: this.options.channelData ? this.options.channelData.channelCode : this.options.channelId, function: '4' },
						() => {
							this.picCap();
						},
						(e) => {
							1103 === e.code && this.wsPlayer.sendErrorMessage(401, { type: 'capture' });
						}
					);
				}),
				$('.ws-close', this.$el).click((e) => {
					this.close();
				}),
				$('.ws-record', this.$el).click((e) => {
					let t = (this.options.channelData || {}).name || '录像';
					this.isRecording
						? ((this.isRecording = !1), this.playSDK.StopRecord(), $(e.target).removeClass('recording'))
						: 'playing' === this.status &&
							this.setAuthority(
								{ channelCode: this.options.channelData ? this.options.channelData.channelCode : this.options.channelId, function: '8' },
								() => {
									(this.isRecording = !0), this.startRecord(`视频_${t}_${i.getDateFormatByUnderline()}`), $(e.target).addClass('recording');
								},
								(e) => {
									1103 === e.code && this.wsPlayer.sendErrorMessage(401, { type: 'record' });
								}
							);
				}),
				$('.more-icon', this.$el).click((e) => {
					(this.showMoreIcon = !this.showMoreIcon), this.setDomVisible($('.opt-icons-vertical', this.$el), this.showMoreIcon);
				});
		}
		picCap(e) {
			let t = e;
			if (!t) {
				t = `抓图_${(this.options.channelData || {}).name || ''}_${i.getDateFormatByUnderline()}`;
			}
			this.playSDK.CapturePic(t + '.png');
		}
		startRecord(e, t, s) {
			const { downloadMp4Record: i, localRecordSize: a } = this.wsPlayer.config;
			let l = 'boolean' == typeof s ? s : i,
				r = t || a;
			this.playSDK.StartRecord(l ? 5 : 0, r, `${e}.${l ? 'mp4' : 'dav'}`);
		}
		closeOtherAudio() {
			this.wsPlayer.playerList.forEach((e) => {
				e.isAudioPlay && e.closeVolume();
			});
		}
		openVolume(e = 1) {
			this.closeOtherAudio(),
				this.playSDK.SetSoundState(!0),
				this.playSDK.SetVolume(e > 1 ? 1 : e),
				this.resumeAudio(),
				$('.ws-audio', this.$el).removeClass('off').addClass('on'),
				(this.isAudioPlay = !0);
		}
		closeVolume() {
			this.playSDK.SetSoundState(!1), this.playSDK.SetVolume(0), $('.ws-audio', this.$el).removeClass('on').addClass('off'), (this.isAudioPlay = !1);
		}
		setAuthority(e, t, s) {
			this.wsPlayer.fetchChannelAuthority
				? this.wsPlayer
						.fetchChannelAuthority(e)
						.then((e) => {
							e.data.result && t();
						})
						.catch((e) => {
							s(e);
						})
				: t();
		}
		resumeAudio() {
			if (window.wsAudioPlayer) window.wsAudioPlayer.manualResume('fromTalk');
			else {
				let e = setInterval(() => {
					window.wsAudioPlayer && (window.wsAudioPlayer.manualResume('fromTalk'), clearInterval(e));
				}, 100);
			}
		}
		setStatus() {}
		play() {
			this.playSDK.SetSpeed(this.speed),
				this.playSDK.Pause(0),
				this.setStatus('playing'),
				$('.ws-record-play', this.wsPlayer.$el).css({ display: 'none' }),
				$('.ws-record-pause', this.wsPlayer.$el).css({ display: '' });
		}
		pause() {
			this.playSDK.Pause(1),
				this.setStatus('pause'),
				$('.ws-record-pause', this.wsPlayer.$el).css({ display: 'none' }),
				$('.ws-record-play', this.wsPlayer.$el).css({ display: '' });
		}
		close(e = !1, t = !1, s = 'closed') {
			if (
				(this.wsPlayer.videoClosed(this.index, e, { ...((this.options && this.options.channelData) || {}) }),
				this.setDomVisible($('.play-pause-wrapper', this.$el), !1),
				(this.videoElem.style.display = 'none'),
				(this.canvasElem.style.display = 'none'),
				this.isTalking && !t && this.stopTalk(),
				(this.speed = 1),
				this.index === this.wsPlayer.selectIndex &&
					('real' === this.wsPlayer.type
						? !e && this.wsPlayer.setPtzChannel()
						: (this.wsPlayer.setTimeLine([]),
							this.wsPlayer.__setPlaySpeed(),
							$('.ws-record-play', this.wsPlayer.$el).css({ display: '' }),
							$('.ws-record-pause', this.wsPlayer.$el).css({ display: 'none' }))),
				this.isRecording && ((this.isRecording = !1), this.playSDK.StopRecord(), $('.ws-record', this.$el).removeClass('recording')),
				this.wsPlayer.config.openIvs && this.playSDK)
			)
				try {
					this.playSDK.CloseIVS();
				} catch (i) {
					console.debug('关闭规则线');
				}
			this.spinner && this.spinner.stop(),
				$('.stream-info', this.$el).text(''),
				this.playSDK &&
					(this.playSDK.StopPullStream(),
					this.playSDK.Stop(),
					window.wsPlayerManager.unbindPlayer(this.playSDK.nPlayPort),
					window.wsPlayerManager.unbindHandlePlayer(this.playSDK.m_rtspvHandle)),
				e || ((this.playSDK = null), (this.options = null)),
				this.setStatus(s);
		}
		setDomVisible(e, t) {
			e && e.css({ visibility: t ? 'visible' : 'hidden' });
		}
		setDomDisplay(e, t) {
			e && e.css({ display: t ? '' : 'none' });
		}
		setDomHiddenDeep(e, t) {
			e && (t ? e.removeClass('hidden-deep') : e.addClass('hidden-deep'));
		}
		updateAdapter(e, t = {}) {
			let s = t.width / t.height,
				i = 'video' === (t.decodeMode || this.decodeMode) ? this.videoElem : this.canvasElem,
				a = i.parentNode;
			t.decodeMode ? ((this.decodeMode = t.decodeMode), (this.width = t.width), (this.height = t.height)) : (s = this.width / this.height);
			let l = '100%',
				r = '100%';
			if ('selfAdaption' === e) {
				let e = a.offsetHeight,
					t = a.offsetWidth,
					n = t / e;
				s > n ? (r = t / s + 'px') : s < n && (l = e * s + 'px'),
					'video' === this.decodeMode
						? ($(i).css({ width: l, height: r, 'object-fit': 'contain' }), $(this.canvasElem).css({ width: l, height: r, 'object-fit': 'contain' }))
						: $(i).css({ width: l, height: r }),
					$(this.ivsCanvasElem).css({ width: l, height: r, 'object-fit': 'contain' }),
					$(this.pztCanvasElem).css({ width: l, height: r, 'object-fit': 'contain' });
			} else
				$(i).css({ width: l, height: r, 'object-fit': 'fill' }),
					'video' === this.decodeMode && $(this.canvasElem).css({ width: l, height: r, 'object-fit': 'fill' }),
					$(this.ivsCanvasElem).css({ width: l, height: r, 'object-fit': 'fill' }),
					$(this.pztCanvasElem).css({ width: l, height: r, 'object-fit': 'fill' });
			this.playSDK &&
				('video' === this.decodeMode && i.offsetWidth && ((this.canvasElem.width = i.offsetWidth), (this.canvasElem.height = i.offsetHeight)),
				(this.ivsCanvasElem.width = i.offsetWidth),
				(this.ivsCanvasElem.height = i.offsetHeight),
				(this.pztCanvasElem.width = i.offsetWidth),
				(this.pztCanvasElem.height = i.offsetHeight));
		}
		renderDefaultStats() {
			let e = $('.default-status', this.$el),
				t = e.width(),
				s = e.height();
			t && s && (t < 200 || s < 200 ? e.css({ transform: 'scale(0.5)' }) : e.css({ transform: 'scale(1)' }));
		}
		updateTopBarStyle() {
			let e = $('.top-control-bar', this.$el).width() - (this.showIcons.streamChangeSelect && 'real' === this.type ? 94 : 0) - 10;
			if (e > 28 * this.showIconNum + 119)
				this.setDomDisplay($('.more-icon', this.$el), !1),
					this.setDomDisplay($('.stream-info', this.$el), !0),
					t.iconConfig.forEach((e, t) => {
						this.setDomDisplay($(`.opt-icons > .${e.buttonParentClass}`, this.$el), !0);
					});
			else if (e > 28 * this.showIconNum)
				this.setDomDisplay($('.more-icon', this.$el), !1),
					this.setDomDisplay($('.stream-info', this.$el), !1),
					t.iconConfig.forEach((e, t) => {
						this.setDomDisplay($(`.opt-icons > .${e.buttonParentClass}`, this.$el), !0);
					});
			else {
				let s = Math.floor(e / 28);
				this.setDomDisplay($('.stream-info', this.$el), !1),
					this.setDomDisplay($('.more-icon', this.$el), !0),
					t.iconConfig.forEach((e, t) => {
						s > t + 2
							? (this.setDomDisplay($(`.opt-icons > .${e.buttonParentClass}`, this.$el), !0),
								this.setDomDisplay($(`.opt-icons-vertical > .${e.buttonParentClass}`, this.$el), !1))
							: (this.setDomDisplay($(`.opt-icons > .${e.buttonParentClass}`, this.$el), !1),
								this.setDomDisplay($(`.opt-icons-vertical > .${e.buttonParentClass}`, this.$el), !0));
					});
			}
		}
	}
	var l =
			(globalThis && globalThis.__assign) ||
			function () {
				return (
					(l =
						Object.assign ||
						function (e) {
							for (var t, s = 1, i = arguments.length; s < i; s++)
								for (var a in (t = arguments[s])) Object.prototype.hasOwnProperty.call(t, a) && (e[a] = t[a]);
							return e;
						}),
					l.apply(this, arguments)
				);
			},
		r = {
			lines: 12,
			length: 7,
			width: 5,
			radius: 10,
			scale: 1,
			corners: 1,
			color: '#000',
			fadeColor: 'transparent',
			animation: 'spinner-line-fade-default',
			rotate: 0,
			direction: 1,
			speed: 1,
			zIndex: 2e9,
			className: 'spinner',
			top: '50%',
			left: '50%',
			shadow: '0 0 1px transparent',
			position: 'absolute',
		},
		n = (function () {
			function e(e) {
				void 0 === e && (e = {}), (this.opts = l(l({}, r), e));
			}
			return (
				(e.prototype.spin = function (e) {
					return (
						this.stop(),
						(this.el = document.createElement('div')),
						(this.el.className = this.opts.className),
						this.el.setAttribute('role', 'progressbar'),
						o(this.el, {
							position: this.opts.position,
							width: 0,
							zIndex: this.opts.zIndex,
							left: this.opts.left,
							top: this.opts.top,
							transform: 'scale(' + this.opts.scale + ')',
						}),
						e && e.insertBefore(this.el, e.firstChild || null),
						(function (e, t) {
							var s = Math.round(t.corners * t.width * 500) / 1e3 + 'px',
								i = 'none';
							!0 === t.shadow ? (i = '0 2px 4px #000') : 'string' == typeof t.shadow && (i = t.shadow);
							for (
								var a = (function (e) {
										for (
											var t = /^\s*([a-zA-Z]+\s+)?(-?\d+(\.\d+)?)([a-zA-Z]*)\s+(-?\d+(\.\d+)?)([a-zA-Z]*)(.*)$/, s = [], i = 0, a = e.split(',');
											i < a.length;
											i++
										) {
											var l = a[i].match(t);
											if (null !== l) {
												var r = +l[2],
													n = +l[5],
													o = l[4],
													d = l[7];
												0 !== r || o || (o = d),
													0 !== n || d || (d = o),
													o === d && s.push({ prefix: l[1] || '', x: r, y: n, xUnits: o, yUnits: d, end: l[8] });
											}
										}
										return s;
									})(i),
									l = 0;
								l < t.lines;
								l++
							) {
								var r = ~~((360 / t.lines) * l + t.rotate),
									n = o(document.createElement('div'), {
										position: 'absolute',
										top: -t.width / 2 + 'px',
										width: t.length + t.width + 'px',
										height: t.width + 'px',
										background: d(t.fadeColor, l),
										borderRadius: s,
										transformOrigin: 'left',
										transform: 'rotate(' + r + 'deg) translateX(' + t.radius + 'px)',
									}),
									h = (l * t.direction) / t.lines / t.speed;
								h -= 1 / t.speed;
								var p = o(document.createElement('div'), {
									width: '100%',
									height: '100%',
									background: d(t.color, l),
									borderRadius: s,
									boxShadow: c(a, r),
									animation: 1 / t.speed + 's linear ' + h + 's infinite ' + t.animation,
								});
								n.appendChild(p), e.appendChild(n);
							}
						})(this.el, this.opts),
						this
					);
				}),
				(e.prototype.stop = function () {
					return (
						this.el &&
							('undefined' != typeof requestAnimationFrame ? cancelAnimationFrame(this.animateId) : clearTimeout(this.animateId),
							this.el.parentNode && this.el.parentNode.removeChild(this.el),
							(this.el = void 0)),
						this
					);
				}),
				e
			);
		})();
	function o(e, t) {
		for (var s in t) e.style[s] = t[s];
		return e;
	}
	function d(e, t) {
		return 'string' == typeof e ? e : e[t % e.length];
	}
	function c(e, t) {
		for (var s = [], i = 0, a = e; i < a.length; i++) {
			var l = a[i],
				r = h(l.x, l.y, t);
			s.push(l.prefix + r[0] + l.xUnits + ' ' + r[1] + l.yUnits + l.end);
		}
		return s.join(', ');
	}
	function h(e, t, s) {
		var i = (s * Math.PI) / 180,
			a = Math.sin(i),
			l = Math.cos(i);
		return [Math.round(1e3 * (e * l + t * a)) / 1e3, Math.round(1e3 * (-e * a + t * l)) / 1e3];
	}
	const p = window.PlaySDKInterface;
	class y extends a {
		constructor(e) {
			super(e),
				(this.currentIndex = e.index),
				(this.wrapperDomId = e.wrapperDomId),
				(this.canvasId = `${this.domId}-livecanvas`),
				(this.ivsCanvasId = `${this.domId}-ivs-livecanvas`),
				(this.pztCanvasId = `${this.domId}-pzt-livecanvas`),
				(this.videoId = `${this.domId}-liveVideo`),
				(this.type = 'real'),
				(this.options = {}),
				this.initDom(),
				(this.defaultStatus = $('.default-status', this.$el)),
				(this.error = $('.error', this.$el)),
				(this.controller = $('.player-control', this.$el)),
				this.controller.dblclick((e) => {
					e.stopPropagation();
				}),
				this.initMouseEvent(),
				this.setStatus('created');
		}
		getTemplate() {
			return `\n        <div id="${this.domId}" style="visibility: hidden; top: 150%; left: 0; width: 0; height: 0;" class="wsplayer-item wsplayer-item-${this.index} ${0 === this.index ? 'selected' : 'unselected'}">\n            <div class="ws-full-content ws-flex">\n                <canvas id="${this.canvasId}" class="kind-stream-canvas" kind-channel-id="0" width="2560" height="1440"></canvas>\n                <video id="${this.videoId}" class="kind-stream-canvas" kind-channel-id="0" muted style="display:none" width="800" height="600"></video>\n                <canvas id="${this.ivsCanvasId}" class="kind-stream-canvas" style="position: absolute" kind-channel-id="0" width="800" height="600"></canvas>\n                <canvas id="${this.pztCanvasId}" class="kind-stream-canvas" style="display: none; position: absolute; z-index: 2;" kind-channel-id="0" width="800" height="600"></canvas>\n            </div>\n            <div class="default-status">\n                <img src="${this.wsPlayer.prefixUrl}/WSPlayer/icon/default.png" alt="">\n            </div>\n            <div class="player-control top-control-bar">\n                <div class="stream">\n                    <div class="select-container">\n                        <div class="select-show select">\n                            <div class="code-stream">主码流</div>\n                            \x3c!-- 下拉箭头 --\x3e\n                            <img src="${this.wsPlayer.prefixUrl}/WSPlayer/icon/spread.png" />\n                        </div>\n                        <div class="stream-type" style="display: none">\n                            <ul class="select-ul">\n                                <li optionValue="主码流" stream-type="1" class="stream-type-item">主码流</li>\n                                <li optionValue="辅码流1" stream-type="2" class="stream-type-item">辅码流1</li>\n                                <li optionValue="辅码流2" stream-type="3" class="stream-type-item">辅码流2</li>\n                            </ul>\n                        </div>\n                    </div>\n                    <span class="stream-info"></span>\n                </div>\n                <div class="opt-icons">\n                    <div class="opt-icon ws-talk talk-icon off" title="对讲"></div>\n                    <div class="opt-icon ws-record record-icon" title="录像"></div>\n                    <div class="opt-icon ws-audio audio-icon off" title="声音"></div>\n                    <div class="opt-icon ws-capture capture-icon" title="抓图"></div>\n                    <div class="opt-icon ws-more more-icon" title="更多">\n                        <div class="opt-icons-vertical">\n                            <div class="ws-talk"><div class="opt-icon talk-icon off"></div>对讲</div>\n                            <div class="ws-record"><div class="opt-icon record-icon"></div>录像</div>\n                            <div class="ws-audio"><div class="opt-icon audio-icon off"></div>声音</div>\n                            <div class="ws-capture"><div class="opt-icon capture-icon"></div>抓图</div>\n                        </div>\n                    </div>\n                    <div class="opt-icon ws-close close-icon" title="关闭"></div>\n                </div>\n            </div>\n            <div class="ws-talking">对讲中...</div>\n            <div class="error">\n                <div class="wsplayer-error-message"></div>\n            </div>\n        </div>\n        `;
		}
		initMouseEvent() {
			super.initMouseEvent();
			let e = this;
			(this.hideTimer = null),
				this.wsPlayer.config.draggable &&
					(this.$el.on('mousedown', (e) => {
						(this.wsPlayer.currentDragWindowIndex = this.currentIndex), e.preventDefault();
					}),
					this.$el.on('mouseup', (e) => {
						this.wsPlayer.changeDragWindow(this.currentIndex), e.preventDefault();
					})),
				this.$el.on('mouseenter mousemove', (e) => {
					['created', 'closed'].includes(this.status) ||
						this.setDomVisible($('.player-control', $(`#${this.wrapperDomId}-${this.currentIndex}`)), !0),
						('playing' !== this.status && 'error' !== this.status) || (this.hideTimer && clearTimeout(this.hideTimer));
				}),
				this.$el.on('mouseleave', (e) => {
					this.hideTimer = setTimeout(() => {
						$('.stream-type', this.$el).hide(),
							this.setDomVisible($('.player-control', $(`#${this.wrapperDomId}-${this.currentIndex}`)), !1),
							(this.streamSelectShow = !1),
							this.setDomVisible($('.opt-icons-vertical', this.$el), !1),
							(this.showMoreIcon = !1);
					}, 300);
				}),
				(this.streamSelectShow = !1),
				$('.select', this.$el).click((e) => {
					this.streamSelectShow
						? ($('.stream-type', this.$el).hide(), (this.streamSelectShow = !1))
						: ($('.stream-type', this.$el).show(), (this.streamSelectShow = !0));
				}),
				$('.stream-type', this.$el).click((t) => {
					let s = t.target.getAttribute('stream-type');
					e.streamType !== s &&
						e.options &&
						('url' === e.playType
							? e.wsPlayer.sendMessage('changeStreamType', { channelData: e.options.channelData, streamType: Number(s), selectIndex: e.index })
							: e.wsPlayer.changeStreamType(e.options.channelData, s, e.index));
				});
		}
		setStreamType(e) {
			this.streamType = e;
			let t = $('.stream-type .select-ul', this.$el)[0].children[e - 1];
			$('.code-stream', this.$el).text($(t).attr('optionValue')), $(t).addClass('stream-type-select').siblings().removeClass('stream-type-select');
		}
		setStatus(e, s) {
			switch ((this.wsPlayer.sendMessage('statusChanged', { status: e, windowIndex: this.index }), (this.status = e), this.status)) {
				case 'created':
				case 'closed':
					this.setDomVisible(this.defaultStatus, !0),
						this.setDomVisible(this.error, !1),
						this.setDomVisible(this.controller, !1),
						(this.videoElem.src = ''),
						$('.audio-icon', this.$el).removeClass('on').addClass('off');
					break;
				case 'ready':
				case 'playing':
				case 'pause':
					this.setDomVisible(this.defaultStatus, !1), this.setDomVisible(this.error, !1);
					break;
				case 'streamError':
					this.close(!1, !1, 'none');
					const { selectIndex: e, channelData: i = {} } = this.options;
					this.wsPlayer.sendMessage(
						'realError',
						{ selectIndex: e, channelData: { ...i } },
						{ code: s.errorCode, msg: t.errorVideoInfo[s.errorCode] }
					);
				case 'error':
					this.setDomVisible(this.defaultStatus, !1),
						$('.wsplayer-error-message', this.$el).text(
							t.errorVideoInfo[s.errorCode] ? t.errorVideoInfo[s.errorCode] : t.errorVideoInfo.defaultErrorMsg
						),
						this.setDomVisible(this.error, !0);
			}
		}
		init(e) {
			if (this.wsPlayer.config.isDynamicLoadLib && !window.m_nModuleInitialized) {
				let t = setTimeout(() => {
					this.init(e), clearTimeout(t);
				}, 100);
				return;
			}
			let t = (this.options || {}).channelId === e.channelId;
			(this.options = e),
				this.playSDK && (this.isAudioPlay && $('.audio-icon', this.$el).removeClass('on').addClass('off'), this.close(!0, t)),
				this.spinner && this.spinner.stop(),
				(this.spinner = new n({ color: '#ffffff' }).spin(this.$el[0])),
				this.setStatus('ready'),
				this.setStreamType(e.streamType),
				this.createPlayer(e);
		}
		startPlay(e, t) {
			'video' === t.decodeMode
				? ((this.videoElem.style.display = ''), (this.canvasElem.style.display = ''), (this.canvasElem.style['z-index'] = 1))
				: ((this.videoElem.style.display = 'none'), (this.canvasElem.style.display = '')),
				this.updateAdapter(e.playerAdapter, t),
				(this.width = t.width),
				(this.height = t.height),
				$('.stream-info', this.$el).text(`${t.encodeMode ? `${t.encodeMode}, ` : ''}${t.width ? `${t.width}*` : ''}${t.height ? t.height : ''}`);
		}
		createPlayer(e) {
			const { onlyLoadSingleLib: s, useH264MSE: i, useH265MSE: a, useNginxProxy: l, openIvs: r, ivsTypeArr: n } = this.wsPlayer.config;
			let o = this;
			(this.playSDK = new p(!s)),
				this.playSDK.SetCallBack('StreamRedirect', function (t) {
					let s = '';
					if (this.wsPlayer.setWSUrl) s = this.wsPlayer.setRedirectWSUrl();
					else if (l) {
						let i = (s = t.split('rtsp://')[1].split('/')[0]);
						s = e.wsURL.split('serverIp=')[0] + 'serverIp=' + i;
					} else s = e.wsURL.split('://')[0] + t.split('rtsp://')[1].split('/')[0];
					o.playSDK.StartPullStream({ strRtspvUri: s, strRtspvUrl: t, strSourceId: '', bTalkService: !1, nRange: 0 });
				}),
				this.playSDK.SetCallBack('GetPlayPort', (e) => {
					(this.playSDK.nPlayPort = e), window.wsPlayerManager.bindPlayer(this.playSDK.nPlayPort, this.playSDK);
				}),
				this.playSDK.SetCallBack('PlayStart', (e) => {
					console.log('PlayStart', e),
						o.spinner.stop(),
						o.setStatus('playing'),
						r
							? (o.playSDK.OpenIVS(o.initIndex),
								n.includes(1) || o.playSDK.SetIvsEnable(3, 0),
								n.includes(2) || (o.playSDK.SetIvsEnable(1, 0), o.playSDK.SetIvsEnable(14, 0)))
							: o.playSDK.CloseIVS();
				}),
				this.playSDK.SetCallBack('DecodeStart', (t) => {
					console.log('DecodeStart', t),
						o.startPlay(e, t),
						o.wsPlayer.sendMessage('realSuccess', { channelData: { ...(e.channelData || {}) }, selectIndex: e.selectIndex });
				}),
				this.playSDK.SetCallBack('Disconnect', () => {
					o.spinner && o.spinner.stop(), !o.isError && o.setStatus('streamError', { errorCode: '410', description: 'Video Stream Abnormality' });
				}),
				this.playSDK.SetCallBack('VideoFrameInfo', (e) => {
					o.wsPlayer.sendMessage('getVideoFrameInfo', { channelData: o.options.channelData, selectIndex: o.index, audioFrameInfo: e });
				}),
				this.playSDK.SetCallBack('AudioFrameInfo', (e) => {
					o.wsPlayer.sendMessage('getAudioFrameInfo', { channelData: o.options.channelData, selectIndex: o.index, audioFrameInfo: e });
				}),
				this.playSDK.SetCallBack('Error', (s) => {
					o.playSDK &&
						((o.isError = !0),
						o.spinner.stop(),
						console.log('Error: ' + JSON.stringify(s)),
						o.setStatus('error', s),
						o.wsPlayer.sendMessage(
							'realError',
							{ selectIndex: e.selectIndex, channelData: { ...(e.channelData || {}) } },
							{ code: s.errorCode, msg: t.errorVideoInfo[s.errorCode] }
						));
				}),
				this.playSDK.Init({
					canvasElem: this.canvasElem,
					videoElem: this.videoElem,
					ivsCanvasElem: this.ivsCanvasElem,
					bPlayBack: 0,
					strDecodeFilePath: `${this.wsPlayer.prefixUrl}/WSPlayer/singleThread`,
				}),
				this.playSDK.SetDecodeMode(i, a),
				(this.playSDK.m_rtspvHandle = this.playSDK.StartPullStream({
					strRtspvUri: e.wsURL,
					strRtspvUrl: e.rtspURL,
					strSourceId: '',
					bTalkService: !1,
					nRange: 0,
					nShortTimeout: this.wsPlayer.rtspResponseTimeout || 8,
					nRtspResponseTimeout: this.wsPlayer.rtspResponseTimeout + 2 || 10,
				})),
				null != this.playSDK.m_rtspvHandle && window.wsPlayerManager.bindHandlePlayer(this.playSDK.m_rtspvHandle, this.playSDK);
		}
		startTalk(e) {
			if (this.wsPlayer.config.isDynamicLoadLib && !window.m_nModuleInitialized) return void this.wsPlayer.sendErrorMessage('502');
			(this.wsPlayer.isTalking = !0), (this.isTalking = !0), $('.talk-icon', this.$el).removeClass('off').addClass('on');
			let s = this;
			(this.talkData = e.talkData),
				this.wsPlayer.__getWSUrl(e).then((i) => {
					(this.talkPlaySDK = new p(!this.wsPlayer.config.onlyLoadSingleLib)),
						this.talkPlaySDK.SetCallBack('GetPlayPort', (e) => {
							(this.talkPlaySDK.nPlayPort = e), window.wsPlayerManager.bindPlayer(this.talkPlaySDK.nPlayPort, this.talkPlaySDK);
						}),
						this.talkPlaySDK.SetCallBack('Error', (i) => {
							s.wsPlayer.sendMessage(
								'talkError',
								{ selectIndex: e.selectIndex, channelData: { ...(this.options.channelData || {}) } },
								{ code: i.errorCode, msg: t.errorVideoInfo[i.errorCode] }
							),
								s.stopTalk();
						}),
						this.talkPlaySDK.Init({
							canvasElem: null,
							videoElem: null,
							ivsCanvasElem: null,
							bPlayBack: 0,
							strDecodeFilePath: `${this.wsPlayer.prefixUrl}/WSPlayer/singleThread`,
						});
					let a = this.talkPlaySDK.StartPullStream({
						strRtspvUri: i,
						strRtspvUrl: e.rtspURL + '&trackID=501',
						strSourceId: '',
						bTalkService: !0,
						nRange: 0,
						nShortTimeout: this.wsPlayer.rtspResponseTimeout || 8,
						nRtspResponseTimeout: this.wsPlayer.rtspResponseTimeout + 2 || 10,
					});
					null != a && window.wsPlayerManager.bindHandlePlayer(a, this.talkPlaySDK),
						'4' === e.talkData.audioType ? this.talkPlaySDK.StartTalk(null, 1) : this.talkPlaySDK.StartTalk(null, 0),
						window.wsPlayerManager.bindPlayer(this.talkPlaySDK.nPlayPort, this.talkPlaySDK),
						$('.ws-talking', this.$el).css({ visibility: 'visible' }),
						this.openVolume();
				});
		}
		talkByUrl(e) {
			if (this.wsPlayer.config.isDynamicLoadLib && !window.m_nModuleInitialized) return void this.wsPlayer.sendErrorMessage('502');
			(this.wsPlayer.isTalking = !0), (this.isTalking = !0), $('.talk-icon', this.$el).removeClass('off').addClass('on');
			let s = this;
			(this.talkPlaySDK = new p(!this.wsPlayer.config.onlyLoadSingleLib)),
				this.talkPlaySDK.SetCallBack('GetPlayPort', (e) => {
					(this.talkPlaySDK.nPlayPort = e), window.wsPlayerManager.bindPlayer(this.talkPlaySDK.nPlayPort, this.talkPlaySDK);
				}),
				this.talkPlaySDK.SetCallBack('Error', (i) => {
					s.wsPlayer.sendMessage('talkError', { selectIndex: e.selectIndex }, { code: i.errorCode, msg: t.errorVideoInfo[i.errorCode] }),
						s.stopTalk();
				}),
				this.talkPlaySDK.Init({
					canvasElem: null,
					videoElem: null,
					ivsCanvasElem: null,
					bPlayBack: 0,
					strDecodeFilePath: `${this.wsPlayer.prefixUrl}/WSPlayer/singleThread`,
				});
			let i = this.talkPlaySDK.StartPullStream({
				strRtspvUri: e.rtspURL,
				strRtspvUrl: e.rtspURL + '&trackID=501',
				strSourceId: '',
				bTalkService: !0,
				nRange: 0,
				nShortTimeout: this.wsPlayer.rtspResponseTimeout || 8,
				nRtspResponseTimeout: this.wsPlayer.rtspResponseTimeout + 2 || 10,
			});
			null != i && window.wsPlayerManager.bindHandlePlayer(i, this.talkPlaySDK),
				'4' === String(e.audioType) ? this.talkPlaySDK.StartTalk(null, 1) : this.talkPlaySDK.StartTalk(null, 0),
				window.wsPlayerManager.bindPlayer(this.talkPlaySDK.nPlayPort, this.talkPlaySDK),
				$('.ws-talking', this.$el).css({ visibility: 'visible' }),
				this.openVolume();
		}
		stopTalk() {
			if (
				(this.talkPlaySDK && window.wsPlayerManager.unbindPlayer(this.talkPlaySDK.nPlayPort),
				this.talkData.session && this.wsPlayer.stopTalk(this.talkData),
				this.isTalking && ((this.wsPlayer.isTalking = !1), (this.isTalking = !1)),
				this.talkPlaySDK && (this.talkPlaySDK.StopTalk(), this.talkPlaySDK.StopPullStream(), (this.talkPlaySDK = null)),
				$('.talk-icon', this.$el).removeClass('on').addClass('off'),
				$('.ws-talking', this.$el).css({ visibility: 'hidden' }),
				this.closeVolume(),
				'url' === this.options.playType)
			) {
				const { selectIndex: e, channelData: t = {} } = this.options;
				this.wsPlayer.sendMessage('stopTalk', { selectIndex: e, channelData: { ...t } });
			}
		}
	}
	const m = window.PlaySDKInterface;
	class u extends a {
		constructor(e) {
			super(e),
				(this.currentIndex = e.index),
				(this.wrapperDomId = e.wrapperDomId),
				(this.speed = 1),
				(this.canvasId = `${this.domId}-recordcanvas`),
				(this.ivsCanvasId = `${this.domId}-ivs-livecanvas`),
				(this.videoId = `${this.domId}-recordVideo`),
				(this.curTimestamp = 0),
				(this.type = 'record'),
				this.initDom(),
				(this.defaultStatus = $('.default-status', this.$el)),
				(this.error = $('.error', this.$el)),
				(this.controller = $('.player-control', this.$el)),
				(this.timeInfo = $('.time-info', this.$el)),
				this.initMouseEvent(),
				this.setStatus('created');
		}
		getTemplate() {
			return `\n        <div id="${this.domId}" style="visibility: hidden; top: 150%; left: 0; width: 0; height: 0;" class="wsplayer-item wsplayer-item-${this.index} ${0 === this.index ? 'selected' : 'unselected'}">\n            <canvas id="${this.canvasId}" class="kind-stream-canvas" kind-channel-id="0" width="2560" height="1440"></canvas>\n            <video id="${this.videoId}" class="kind-stream-canvas" kind-channel-id="0" muted style="display:none" width="800" height="600"></video>\n            <canvas id="${this.ivsCanvasId}" class="kind-stream-canvas" style="position: absolute" kind-channel-id="0" width="800" height="600"></canvas>\n            <div class="default-status">\n                <img src="${this.wsPlayer.prefixUrl}/WSPlayer/icon/default.png" alt="">\n            </div>\n            <div class="player-control top-control-bar">\n                <span class="stream-info"></span>\n                <div class="opt-icons">\n                    <div class="opt-icon ws-record record-icon" title="录像"></div>\n                    <div class="opt-icon ws-audio audio-icon off" title="声音"></div>\n                    <div class="opt-icon ws-capture capture-icon" title="抓图"></div>\n                    <div class="opt-icon ws-more more-icon" title="更多">\n                        <div class="opt-icons-vertical">\n                            <div class="ws-record"><div class="opt-icon record-icon"></div>录像</div>\n                            <div class="ws-audio"><div class="opt-icon audio-icon off"></div>声音</div>\n                            <div class="ws-capture"><div class="opt-icon capture-icon"></div>抓图</div>\n                        </div>\n                    </div>\n                    <div class="ws-close opt-icon close-icon" title="关闭"></div>\n                </div>\n            </div>\n            <div class="player-control record-control-bar">\n                <div class="wsplayer-progress-bar">\n                    <div class="progress-bar_background"></div>\n                    <div class="progress-bar_hover_light"></div>\n                    <div class="progress-bar_light"></div>\n                </div>\n                <div class="record-control-left">\n                    <div class="opt-icon play-ctrl-btn play-icon play"></div>\n                    <div class="time-info"></div>/<div class="time-long"></div>\n                </div>\n                <div class="record-control-right">\n                    <div class="opt-icon close-icon"></div>\n                </div>\n            </div>\n            <div class="error">\n                <div class="wsplayer-error-message"></div>\n            </div>\n            <div class="play-pause-wrapper">\n                <div class="play-ctrl-btn center-play-icon"></div>\n            </div>\n        </div>\n        `;
		}
		initMouseEvent() {
			super.initMouseEvent(),
				(this.hideTimer = null),
				this.wsPlayer.config.draggable &&
					(this.$el.on('mousedown', (e) => {
						(this.wsPlayer.currentDragWindowIndex = this.currentIndex), e.preventDefault();
					}),
					this.$el.on('mouseup', (e) => {
						this.wsPlayer.changeDragWindow(this.currentIndex), e.preventDefault();
					})),
				this.$el.on('mouseenter mousemove', (e) => {
					['created', 'closed'].includes(this.status) ||
						this.setDomVisible($('.player-control', $(`#${this.wrapperDomId}-${this.currentIndex}`)), !0),
						'playing' === this.status
							? this.hideTimer && clearTimeout(this.hideTimer)
							: 'ready' === this.status && this.setDomVisible(this.progressBar, !0);
				}),
				this.$el.on('mouseleave', (e) => {
					'pause' !== this.status &&
						(this.hideTimer = setTimeout(() => {
							this.setDomVisible($('.player-control', $(`#${this.wrapperDomId}-${this.currentIndex}`)), !1),
								this.setDomVisible($('.opt-icons-vertical', this.$el), !1),
								(this.showMoreIcon = !1);
						}, 300));
				}),
				$('.wsplayer-progress-bar', this.$el).on('mousemove', (e) => {
					$('.progress-bar_hover_light', this.$el).css({ width: e.offsetX + 'px' });
				}),
				$('.wsplayer-progress-bar', this.$el).on('mouseleave', (e) => {
					$('.progress-bar_hover_light', this.$el).css({ width: 0 });
				}),
				$('.play-ctrl-btn', this.$el).click((e) => {
					'playing' === this.status
						? (this.pause(), $('.play-icon', this.$el).removeClass('play').addClass('pause'))
						: (this.play(), $('.play-icon', this.$el).removeClass('pause').addClass('play'));
				});
		}
		setStatus(e, s) {
			switch ((this.wsPlayer.sendMessage('statusChanged', { status: e, windowIndex: this.index }), (this.status = e), this.status)) {
				case 'created':
				case 'closed':
					this.setDomVisible(this.defaultStatus, !0),
						this.setDomVisible(this.error, !1),
						this.setDomVisible(this.controller, !1),
						$('.audio-icon', this.$el).removeClass('on').addClass('off');
					break;
				case 'ready':
					this.setDomVisible(this.defaultStatus, !1), this.setDomVisible(this.error, !1);
					break;
				case 'playing':
					this.wsPlayer.selectIndex === this.index && $('#ws-record-time-box').css({ visibility: 'visible' }),
						this.setDomVisible(this.defaultStatus, !1),
						this.setDomVisible(this.error, !1),
						this.setDomVisible($('.play-pause-wrapper', this.$el), !1);
					break;
				case 'pause':
					this.setDomVisible(this.defaultStatus, !1),
						this.setDomVisible(this.error, !1),
						this.setDomVisible(this.controller, !1),
						this.setDomVisible($('.play-pause-wrapper', this.$el), !0);
					break;
				case 'streamError':
					setTimeout(() => this.close(!1, !1, 'none'), 0);
					const { selectIndex: e, channelData: i = {} } = this.options;
					'411' === s.errorCode
						? this.wsPlayer.sendMessage('recordFinish', { selectIndex: e, channelData: { ...i } })
						: this.wsPlayer.sendMessage(
								'recordError',
								{ selectIndex: e, channelData: { ...i } },
								{ code: s.errorCode, msg: t.errorVideoInfo[s.errorCode] }
							);
				case 'error':
					this.setDomVisible(this.defaultStatus, !1),
						$('.wsplayer-error-message', this.$el).text(
							t.errorVideoInfo[s.errorCode] ? t.errorVideoInfo[s.errorCode] : t.errorVideoInfo.defaultErrorMsg
						),
						this.setDomVisible(this.error, !0);
			}
		}
		init(e) {
			if (!this.wsPlayer.config.isDynamicLoadLib || window.m_nModuleInitialized)
				(this.options = e),
					this.playSDK && (this.isAudioPlay && $('.audio-icon', this.$el).removeClass('on').addClass('off'), this.close(!0)),
					this.spinner && this.spinner.stop(),
					(this.spinner = new n({ color: '#ffffff' }).spin(this.$el[0])),
					this.createPlayer(e);
			else {
				let t = setTimeout(() => {
					this.init(e), clearTimeout(t);
				}, 100);
			}
		}
		createPlayer(e) {
			let s = this;
			(this.playSDK = new m(!this.wsPlayer.config.onlyLoadSingleLib)),
				this.playSDK.SetCallBack('StreamRedirect', function (t) {
					let i = '';
					if (this.wsPlayer.setWSUrl) i = this.wsPlayer.setRedirectWSUrl(e.wsURL, t);
					else if (this.wsPlayer.config.useNginxProxy) {
						let s = (i = t.split('rtsp://')[1].split('/')[0]);
						i = e.wsURL.split('serverIp=')[0] + 'serverIp=' + s;
					} else i = e.wsURL.split('://')[0] + t.split('rtsp://')[1].split('/')[0];
					s.playSDK.StartPullStream({
						strRtspvUri: i,
						strRtspvUrl: t,
						strSourceId: '',
						bTalkService: !1,
						nRange: 0,
						nShortTimeout: rtspResponseTimeout || 8,
						nRtspResponseTimeout: rtspResponseTimeout + 2 || 10,
					});
				}),
				this.playSDK.SetCallBack('GetPlayPort', (e) => {
					(this.playSDK.nPlayPort = e), window.wsPlayerManager.bindPlayer(this.playSDK.nPlayPort, this.playSDK);
				}),
				this.playSDK.SetCallBack('PlayStart', (e) => {
					console.log('PlayStart'),
						s.setStatus('playing'),
						s.wsPlayer.selectIndex === s.index &&
							($('.ws-record-play', s.wsPlayer.$el).css({ display: 'none' }), $('.ws-record-pause', s.wsPlayer.$el).css({ display: 'block' })),
						s.wsPlayer.config.openIvs
							? (s.playSDK.OpenIVS(s.initIndex),
								s.wsPlayer.config.ivsTypeArr.includes(1) || s.playSDK.SetIvsEnable(3, 0),
								s.wsPlayer.config.ivsTypeArr.includes(2) || (s.playSDK.SetIvsEnable(1, 0), s.playSDK.SetIvsEnable(14, 0)))
							: s.playSDK.CloseIVS();
				}),
				this.playSDK.SetCallBack('DecodeStart', (t) => {
					console.log('DecodeStart', t),
						s.DecodeStart && s.wsPlayer.config.playCenterRecordByTime && (s.DecodeStart(), (s.DecodeStart = null)),
						s.spinner.stop(),
						'video' === t.decodeMode
							? ((s.videoElem.style.display = ''), (s.canvasElem.style.display = 'none'))
							: ((s.videoElem.style.display = 'none'), (s.canvasElem.style.display = '')),
						s.updateAdapter(e.playerAdapter, t),
						$('.stream-info', s.$el).text(t.width ? `${t.encodeMode}, ${t.width}*${t.height}` : t.encodeMode),
						s.wsPlayer.sendMessage('recordSuccess', { selectIndex: e.selectIndex, channelData: { ...(e.channelData || {}) } });
				}),
				this.playSDK.SetCallBack('Disconnect', () => {
					s.spinner && s.spinner.stop(), !s.isError && s.setStatus('streamError', { errorCode: '410', description: 'Video Stream Abnormality' });
				}),
				this.playSDK.SetCallBack('VideoFrameInfo', (e) => {
					'playing' === s.status && s.wsPlayer.__setPlayingTime(s.index, e.nYear, e.nMonth, e.nDay, e.nHour, e.nMinute, e.nSecond),
						s.wsPlayer.sendMessage('getVideoFrameInfo', { channelData: s.options.channelData, selectIndex: s.index, audioFrameInfo: e });
				}),
				this.playSDK.SetCallBack('AudioFrameInfo', (e) => {
					s.wsPlayer.sendMessage('getAudioFrameInfo', { channelData: s.options.channelData, selectIndex: s.index, audioFrameInfo: e });
				}),
				this.playSDK.SetCallBack('PlayBackStreamRange', (e) => {
					s.wsPlayer.sendMessage('getPlayBackStreamRange', { channelData: s.options.channelData, selectIndex: s.index, recordRange: e });
				}),
				this.playSDK.SetCallBack('StreamPlayOver', (e) => {
					console.log('回放播放完成', e);
					let t = '',
						i = s.options.ssId,
						a = s.options.ssIdList || [];
					i && (t = a[a.indexOf(i) + 1]),
						!s.options.playRecordByTime && t
							? s.wsPlayer.playNextRecord(s.index, t)
							: s.setStatus('streamError', { errorCode: '411', description: 'Record Finished' });
				}),
				this.playSDK.SetCallBack('Error', (i) => {
					if (s.playSDK) {
						if (((s.isError = !0), '408' === i.errorCode)) return;
						s.spinner.stop(),
							console.log('Error: ' + JSON.stringify(i)),
							s.setStatus('error', i),
							s.wsPlayer.sendMessage(
								'recordError',
								{ selectIndex: e.selectIndex, channelData: { ...(e.channelData || {}) } },
								{ code: i.errorCode, msg: t.errorVideoInfo[i.errorCode] }
							);
					}
				}),
				this.playSDK.Init({
					canvasElem: this.canvasElem,
					videoElem: this.videoElem,
					ivsCanvasElem: this.ivsCanvasElem,
					bPlayBack: 1,
					strDecodeFilePath: `${this.wsPlayer.prefixUrl}/WSPlayer/singleThread`,
				}),
				(this.playSDK.m_rtspvHandle = this.playSDK.StartPullStream({
					strRtspvUri: e.wsURL,
					strRtspvUrl: e.rtspURL,
					strSourceId: '',
					bTalkService: !1,
					nRange: 0,
					nShortTimeout: this.wsPlayer.rtspResponseTimeout || 8,
					nRtspResponseTimeout: this.wsPlayer.rtspResponseTimeout + 2 || 10,
				})),
				null != this.playSDK.m_rtspvHandle && window.wsPlayerManager.bindHandlePlayer(this.playSDK.m_rtspvHandle, this.playSDK),
				(this.timeLong = e.endTime - e.startTime);
			let i = this.timeLong % 60,
				a = parseInt(this.timeLong / 60) % 60,
				l = parseInt(this.timeLong / 3600) % 60;
			(this.timeLongStr = `${l > 0 ? l + ':' : ''}${a < 10 ? '0' + a : a}:${i < 10 ? '0' + i : i}`),
				$('.time-long', this.$el).text(this.timeLongStr),
				this.setStatus('ready'),
				window.wsPlayerManager.bindPlayer(this.playSDK.nPlayPort, this.playSDK);
		}
		playSpeed(e) {
			(this.speed = e), 1 !== e && this.closeVolume(), this.playSDK && this.playSDK.SetSpeed(e);
		}
	}
	class w {
		constructor() {
			__publicField(this, 'cPlusMediaFrameCallBack', function (e, t, s, i) {
				this.handleToPlayer[e] && this.handleToPlayer[e].InputData(s, i);
			}),
				__publicField(this, 'cPlusRtspMsgCallBack', function (e, t, s) {
					switch (t) {
						case 4096:
							this.handleToPlayer[e].StreamFailedCallback(s),
								this.handleToPlayer[e].StopPullStream(),
								this.handleToPlayer[e].StreamDisconnectCallback();
							break;
						case 4097:
							break;
						case 4100:
							this.handleToPlayer[e].StreamFinishCallback();
							break;
						case 4104:
							this.handleToPlayer[e].StreamRedirectCallback(s);
					}
				}),
				__publicField(this, 'cPlusRtsvMsgCallBack', function (e, t, s) {
					switch (t) {
						case 16385:
							break;
						case 16386:
							this.handleToPlayer[e] && this.handleToPlayer[e].StreamFinishCallback();
					}
				}),
				__publicField(this, 'cIVSDrawDataCallBack', function (e, t, s, i, a) {}),
				(this.wsPlayerList = []),
				(this.portToPlayer = {}),
				(this.handleToPlayer = {}),
				(window.cPlusVisibleDecCallBack = this.cPlusVisibleDecCallBack.bind(this)),
				(window.cDigitalSignCallBack = this.cDigitalSignCallBack.bind(this)),
				(window.cRecordDataCallBack = this.cRecordDataCallBack.bind(this)),
				(window.cIVSDrawDataCallBack = this.cIVSDrawDataCallBack.bind(this)),
				(window.cPlusMediaFrameCallBack = this.cPlusMediaFrameCallBack.bind(this)),
				(window.cPlusRtspMsgCallBack = this.cPlusRtspMsgCallBack.bind(this)),
				(window.cPlusRtsvMsgCallBack = this.cPlusRtsvMsgCallBack.bind(this));
		}
		cPlusVisibleDecCallBack(e, t, s, i, a, l) {
			this.portToPlayer[e] && this.portToPlayer[e].SetFrameData(e, t, s, i, a, l);
		}
		cDigitalSignCallBack(e, t, s) {
			this.portToPlayer[e] && this.portToPlayer[e].SetDecryptionResult(e, t, s);
		}
		cRecordDataCallBack(e, t, s, i, a) {
			this.portToPlayer[e] && this.portToPlayer[e].SetRecordData(e, t, s, i, a);
		}
		bindPlayer(e, t) {
			this.portToPlayer[e] || (this.portToPlayer[e] = t);
		}
		unbindPlayer(e) {
			this.portToPlayer[e] = null;
		}
		bindHandlePlayer(e, t) {
			this.handleToPlayer[e] || (this.handleToPlayer[e] = t);
		}
		unbindHandlePlayer(e) {
			this.handleToPlayer[e] = null;
		}
		addWSPlayer(e) {
			this.wsPlayerList.push();
		}
		removeWSPlayer(e) {
			this.wsPlayerList = this.wsPlayerList.filter((t) => t === e);
		}
	}
	const S = {
			clientType: 'WINPC',
			clientMac: '30:9c:23:79:40:08',
			clientPushId: '',
			project: 'PSDK',
			method: 'MTS.Video.StartVideo',
			data: {
				optional: '/admin/API/MTS/Video/StartVideo',
				dataType: '3',
				streamType: '2',
				channelId: '',
				trackId: '',
				clientSupportWSSDirect: 1,
				enableXNetFlag: 1,
			},
		},
		v = {
			clientType: 'WINPC',
			clientMac: '30:9c:23:79:40:08',
			clientPushId: '',
			project: 'PSDK',
			method: 'MTS.Audio.StartTalk',
			data: {
				optional: '/admin/API/MTS/Audio/StartTalk?token=ff93dabe5d754ea8acb0a95dbe6c4a0f',
				source: '',
				deviceCode: '',
				talkType: '1',
				target: '',
				audioBit: 16,
				audioType: 2,
				broadcastChannels: '',
				sampleRate: 8e3,
				talkmode: '',
				channelSeq: '0',
				enableGBParamAutoAdapt: 1,
			},
		},
		g = {
			clientType: 'WINPC',
			clientMac: '30:9c:23:79:40:08',
			clientPushId: '',
			project: 'PSDK',
			method: 'SS.Record.QueryRecords',
			data: {
				cardNo: '',
				optional: '/admin/API/SS/Record/QueryRecords',
				diskPath: '',
				startIndex: '',
				streamType: '0',
				recordType: '0',
				recordSource: '3',
				endIndex: '',
				startTime: '',
				endTime: '',
				channelId: '',
			},
		},
		f = {
			clientType: 'WINPC',
			clientMac: '30:9c:23:79:40:08',
			clientPushId: '',
			project: 'PSDK',
			method: 'SS.Playback.StartPlaybackByTime',
			data: {
				nvrId: '',
				optional: '/admin/API/SS/Playback/StartPlaybackByTime',
				recordType: '0',
				recordSource: '1',
				streamType: '1',
				channelId: '',
				startTime: '',
				endTime: '',
				clientSupportWSSDirect: 1,
				enableXNetFlag: 1,
			},
		},
		P = { 1: 307, 3: 308, 4: 309, 5: 310, 8: 311, 101: 312 };
	class I {
		constructor(e) {
			(this.realPlayer = null),
				(this.recordPlayer = null),
				(this.playCenterRecordByTime = e.playCenterRecordByTime),
				'real' === e.type ? (this.realPlayer = e.player) : (this.recordPlayer = e.player),
				(this.playIndex = 0),
				(this.recordList = []),
				(this.getRealRtsp = e.getRealRtsp),
				(this.getRecords = e.getRecords),
				(this.getRecordRtspByTime = e.getRecordRtspByTime),
				(this.getRecordRtspByFile = e.getRecordRtspByFile),
				(this.getTalkRtsp = e.getTalkRtsp),
				(this.stopTalk = e.stopTalk);
		}
		getCurrentRtsp(e) {
			let t = this.getRTSPUrls(e);
			return t.find((e) => e.includes(window.location.hostname)) || t[0];
		}
		getRTSPUrls(e) {
			return e.split('|').filter((e) => !e.includes('localhost') && !e.includes('127.0.0.1') && !e.startsWith('rtsp://['));
		}
		getWSUrl(e) {
			return this.getRTSPUrls(e).map((e) => e.split('//')[1].split('/')[0]);
		}
		wssRedirectParam(e) {
			'wss' === ((this.realPlayer || this.recordPlayer).protocol || ('https:' === window.location.protocol ? 'wss' : 'ws')) &&
				((e.data.clientSupportWSSDirect = 1), (e.data.enableXNetFlag = 1));
		}
		openSomeWindow(e) {
			let t = this.realPlayer || this.recordPlayer;
			e > t.showNum &&
				(e < t.maxWindow ? (this.playNum = e > 16 ? 25 : e > 9 ? 16 : e > 4 ? 9 : 4) : (this.playNum = t.maxWindow), t.setPlayerNum(this.playNum));
		}
		playRealVideo(e, t = '2', s, a = !1) {
			i.validFunction(this.getRealRtsp)
				? (this.openSomeWindow(e.length),
					e.map((i, l) => {
						let r = s > -1 ? s : this.playIndex;
						e.length > 1 && (r += l),
							(S.data.streamType = t),
							(S.data.channelId = i.id),
							this.wssRedirectParam(S),
							this.getRealRtsp(JSON.parse(JSON.stringify(S))).then(
								(e) => {
									(e.rtspURL = this.getCurrentRtsp(e.url) + '?token=' + e.token),
										this.realPlayer.playReal({
											selectIndex: r,
											streamServerIp: e.innerIp,
											rtspURL: e.rtspURL,
											channelId: i.id,
											channelData: i,
											streamType: t,
											wsList: this.getWSUrl(e.url),
											wssDirect: e.wssDirect,
										});
								},
								(e) => {
									'27001007' === e.code
										? this.realPlayer.sendErrorMessage(102, { channelList: [i], apiErrorInfo: e })
										: a
											? this.realPlayer.sendErrorMessage(103, { channelList: [i], apiErrorInfo: e })
											: this.playRealVideo([i], '1', r, !0);
								}
							);
					}))
				: this.realPlayer.sendErrorMessage(608, { insert: ['请求实时预览接口', 'getRealRtsp'] });
		}
		startTalk(e) {
			if (!i.validFunction(this.getTalkRtsp)) return void this.realPlayer.sendErrorMessage(608, { insert: ['请求对讲接口', 'getTalkRtsp'] });
			(v.data.deviceCode = e.deviceCode),
				(v.data.audioBit = e.audioBit || 16),
				(v.data.sampleRate = e.sampleRate || 8e3),
				[1, 6, 10, 43].includes(e.deviceType)
					? ((v.data.talkType = '2'), (v.data.channelSeq = e.channelSeq))
					: ((v.data.talkType = '1'), (v.data.channelSeq = '0'));
			let t = { talkType: v.data.talkType, deviceCode: e.deviceCode, session: '', channelSeq: v.data.channelSeq, audioType: 2 },
				s = (e) => {
					let s = this.getCurrentRtsp(e.url) + '?token=' + e.token;
					this.realPlayer.playerList[this.realPlayer.talkIndex].startTalk({
						rtspURL: s,
						streamServerIp: e.innerIp,
						wsList: this.getWSUrl(e.url),
						talkData: t,
					});
				};
			this.getTalkRtsp(JSON.parse(JSON.stringify(v)))
				.then((i) => {
					if (((t.session = i.session), (t.audioType = i.audioType), '2' !== i.audioType))
						return (
							this.stopTalk({ data: t }),
							(v.data.audioType = 4),
							void this.getTalkRtsp(JSON.parse(JSON.stringify(v)))
								.then((i) => {
									if (((t.session = i.session), (t.audioType = i.audioType), '4' !== i.audioType))
										return this.realPlayer.sendErrorMessage(P[i.audioType], { channelList: [e] }), void this.stopTalk({ data: t });
									s(i);
								})
								.catch((t) => {
									this.realPlayer.sendErrorMessage(304, { channelList: [e], apiErrorInfo: t });
								})
						);
					s(i);
				})
				.catch((t) => {
					this.realPlayer.sendErrorMessage(304, { channelList: [e], apiErrorInfo: t });
				});
		}
		getRecordList(e, t) {
			if (!i.validFunction(this.getRecords)) return void this.recordPlayer.sendErrorMessage(608, { insert: ['请求录像接口', 'getRecords'] });
			(g.data.streamType = e.streamType || '0'),
				(g.data.recordType = e.recordType || '0'),
				(g.data.recordSource = e.recordSource),
				(g.data.startTime = e.startTime),
				(g.data.endTime = e.endTime);
			let s = 'number' == typeof e.windowIndex ? e.windowIndex : e.channelList.length > 1 ? 0 : this.playIndex;
			e.channelList.forEach((i) => {
				(g.data.channelId = i.id),
					this.getRecords(JSON.parse(JSON.stringify(g))).then(
						(a) => {
							let l = (a.records || []).sort((e, t) => e.startTime - t.startTime);
							l.length
								? (e.channelList.length > 1 && this.openSomeWindow(s + 1),
									this.getRecordRtsp(
										{ ...e, channel: i },
										l.map((e) => ((e.isImportant = '2' === e.recordType), e)),
										!e.isUpdateRecords,
										s++,
										t
									))
								: this.recordPlayer.sendErrorMessage(201, { channelList: [i] });
						},
						(e) => {
							this.recordPlayer.sendErrorMessage(202, { channelList: [i], apiErrorInfo: e });
						}
					);
			});
		}
		getRecordRtsp(e, t, s = !0, i, a) {
			let l = null,
				r = t[0].recordSource || e.recordSource,
				n = e.ssId,
				o = [];
			(f.data.streamType = t[0].streamType || e.streamType || '0'),
				(f.data.recordType = '1'),
				(f.data.recordSource = r),
				(f.data.startTime = e.startTime),
				(f.data.endTime = e.endTime),
				(f.data.channelId = e.channel.id),
				(f.data.streamId = t[0].streamId || ''),
				(n = n || t[0].ssId),
				(o = Array.from(new Set(t.map((e) => e.ssId)))),
				(f.data.ssId = n),
				this.wssRedirectParam(f),
				(l = this.getRecordRtspByTime(JSON.parse(JSON.stringify(f)))),
				l &&
					l.then(
						(l) => {
							if (
								((l.channelId = e.channel.id),
								(l.rtspURL = this.getCurrentRtsp(l.url) + '?token=' + l.token),
								(l.wsList = this.getWSUrl(l.url)),
								!l.rtspURL)
							)
								return this.recordPlayer.sendErrorMessage(201, { channelList: [e.channel] }), void console.warn('所选通道未查询到录像文件');
							(l.channelData = e.channel),
								(l.startTime = e.startTime),
								(l.endTime = e.endTime),
								this.recordPlay(l, i, n, o, e.isJumpPlay, a, true, t).then(() => {
									let a = this.recordList[i];
									if (s) this.recordList[i] = { ...e, recordList: t, recordIndex: 0, isPlaying: !0 };
									else {
										let e = t[0].recordName;
										(a.recordIndex = a.recordList.findIndex((t) => t.recordName === e)), (a.isPlaying = !0);
									}
									this.playIndex === i && (s || ((t = a.recordList), (a.isPlaying = !0)), this.setTimeLine(t));
								});
						},
						(t) => {
							this.recordPlayer.sendErrorMessage(203, { channelList: [e.channel], apiErrorInfo: t });
						}
					);
		}
		recordPlay(e, t, s, i, a, l, r, n) {
			return new Promise((o) => {
				this.recordPlayer
					.playRecord(
						{
							...e,
							streamServerIp: e.innerIp,
							selectIndex: t,
							ssId: s,
							ssIdList: i,
							isJumpPlay: a,
							playRecordByTime: r || (this.recordPlayer.config.playCenterRecordByTime && !!s),
							recordList: n,
						},
						l
					)
					.then(() => o());
			});
		}
		setTimeLine(e) {
			this.recordPlayer.setTimeLine(e);
		}
		clickRecordTimeLine(e, t) {
			let s = this.recordList[this.playIndex],
				i = s.startTime;
			(i = new Date(1e3 * i).setHours(0)),
				(i = new Date(i).setMinutes(0)),
				(i = new Date(i).setSeconds(0) / 1e3),
				this.playCenterRecordByTime || (i += e);
			let a = {
				channelList: [s.channel],
				startTime: i,
				endTime: s.endTime,
				recordSource: s.recordSource,
				isUpdateRecords: !0,
				ssId: t,
				isJumpPlay: !0,
			};
			this.getRecordList(a, {
				DecodeStart() {
					this.player.playByTime(e);
				},
			});
		}
		playNextRecord(e, t) {
			if (t) {
				if (!i.validFunction(this.getRecordRtspByTime))
					return void this.recordPlayer.sendErrorMessage(608, { insert: ['请求录像接口', 'getRecordRtspByTime'] });
				let s = this.recordList[e],
					a = s.recordList.find((e) => e.ssId === t);
				(f.data.streamType = a.streamType || '0'),
					(f.data.recordType = '1'),
					(f.data.recordSource = a.recordSource),
					(f.data.startTime = new Date(1e3 * a.startTime).setHours(0, 0, 0) / 1e3),
					(f.data.endTime = new Date(1e3 * a.endTime).setHours(23, 59, 59) / 1e3),
					(f.data.channelId = a.channelId),
					(f.data.ssId = t),
					(f.data.streamId = a.streamId || ''),
					this.wssRedirectParam(f);
				let l = Array.from(new Set(s.recordList.map((e) => e.ssId)));
				this.getRecordRtspByTime(JSON.parse(JSON.stringify(f))).then((i) => {
					(i.channelId = a.channelId),
						(i.rtspURL = this.getCurrentRtsp(i.url) + '?token=' + i.token),
						(i.wsList = this.getWSUrl(i.url)),
						(i.startTime = f.data.startTime),
						(i.endTime = f.data.endTime),
						this.recordPlay(i, e, t, l, !0).then(() => {
							this.setTimeLine(s.recordList);
						});
				});
			} else;
		}
		changeTimeLine(e) {
			let t = this.recordList[e];
			t && t.isPlaying && this.setTimeLine(t.recordList);
		}
		videoClosed(e, t, s) {
			this.recordList[e] && (this.recordList[e].isPlaying = !1);
		}
		setPlayIndex(e) {
			this.playIndex = e;
		}
	}
	class x {
		constructor(e = {}, t) {
			(this.el = e.el),
				(this.wsPlayer = t),
				(this.prefixUrl = e.prefixUrl || './static'),
				(this.$el = $('#' + this.el)),
				this.$el && !this.$el.children().length && this.__createPanTilt(),
				(this.channel = null),
				(this.channelCodeForPositionList = []),
				(this.setPtzDirection = e.setPtzDirection),
				(this.setPtzCamera = e.setPtzCamera),
				(this.controlSitPosition = e.controlSitPosition),
				(this.mousedownCanvasEvent = this.__mousedownCanvasEvent.bind(this)),
				(this.mousemoveCanvasEvent = this.__mousemoveCanvasEvent.bind(this)),
				(this.mouseupCanvasEvent = this.__mouseupCanvasEvent.bind(this)),
				(this.clickDirectFlag = !1),
				(this.setPtzDirectionPromiseList = []),
				(this.setPtzDirectionRun = !1),
				(this.setPtzCameraPromiseList = []),
				(this.setPtzCameraRun = !1);
		}
		setChannel(e) {
			this.channel = { ...e };
			let t = this.wsPlayer.selectIndex,
				s = this.channelCodeForPositionList[t];
			if (!e)
				return (
					$('.ws-pan-tilt-mask', this.$el).css({ display: 'block' }),
					$('.ws-pan-tilt-mask-position', this.$el).css({ display: 'none' }),
					void this.__removeCanvasEvent()
				);
			s
				? s !== e.id
					? ((this.channelCodeForPositionList[t] = null), this.__removeCanvasEvent())
					: this.__openSitPosition(!0)
				: this.openSitPositionFlag && this.__removeCanvasEvent();
			let i = e.capability;
			switch (e.cameraType + '') {
				case '1':
					parseInt(i, 2) & parseInt('100', 2) || parseInt(i, 2) & parseInt('10000000000000000', 2)
						? $('.ws-pan-tilt-mask-zoom', this.$el).css({ display: 'none' })
						: $('.ws-pan-tilt-mask-zoom', this.$el).css({ display: 'block' }),
						parseInt(i, 2) & parseInt('10000000000000000', 2)
							? ($('.ws-pan-tilt-mask-direction', this.$el).css({ display: 'none' }),
								$('.ws-pan-tilt-mask-position', this.$el).css({ display: 'block' }),
								this.__removeCanvasEvent())
							: ($('.ws-pan-tilt-mask-direction', this.$el).css({ display: 'block' }),
								$('.ws-pan-tilt-mask-position', this.$el).css({ display: 'none' })),
						$('.ws-pan-tilt-mask-aperture', this.$el).css({ display: 'block' });
					break;
				case '2':
					$('.ws-pan-tilt-mask', this.$el).css({ display: 'none' }), $('.ws-pan-tilt-mask-position', this.$el).css({ display: 'none' });
					break;
				default:
					$('.ws-pan-tilt-mask', this.$el).css({ display: 'block' }),
						$('.ws-pan-tilt-mask-position', this.$el).css({ display: 'none' }),
						this.__removeCanvasEvent();
			}
		}
		__createPanTilt() {
			this.$el.append(
				`\n            <div class="ws-pan-tilt-control">\n                <div class="ws-pan-tilt-circle-wrapper">\n                    \x3c!--云台方向控制--\x3e\n                    <div class="ws-pan-tilt-circle-rotate">\n                        <div class="ws-pan-tilt-circle">\n                            <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-t.svg" title="上" direct="1"/></div>\n                            <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-rt.svg" title="右上" direct="7"/></div>\n                            <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-r.svg" title="右" direct="4"/></div>\n                            <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-rb.svg" title="右下" direct="8"/></div>\n                            <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-b.svg" title="下" direct="2"/></div>\n                            <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-lb.svg" title="左下" direct="6"/></div>\n                            <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-l.svg" title="左" direct="3"/></div>\n                            <div class="ws-pan-tilt-direction-item"><img src="${this.prefixUrl}/WSPlayer/icon/arrow-lt.svg" title="左上" direct="5"/></div>\n                            <div class="ws-pan-tilt-inner-circle">\n                                <img\n                                    class="ws-pan-tilt-pzt-select"\n                                    src="${this.prefixUrl}/WSPlayer/icon/ptz-select.svg"\n                                    title="三维定位"\n                                />\n                            </div>\n                        </div>\n                    </div>\n                </div>\n                \n                \x3c!--云台变倍、聚焦、光圈控制--\x3e\n                <div class="ws-cloud-control-wrapper">\n                    <div class="ws-pan-tilt-control-item"><img src="${this.prefixUrl}/WSPlayer/icon/ptz-icon1.svg" title="变倍-" operateType="1" direct="2"/></div>\n                    <div class="ws-pan-tilt-control-item"><img src="${this.prefixUrl}/WSPlayer/icon/ptz-icon2.svg" title="变倍+" operateType="1" direct="1"/></div>\n                    <div class="cloud-control-separate"></div>\n                    <div class="ws-pan-tilt-control-item"><img src="${this.prefixUrl}/WSPlayer/icon/ptz-icon3.svg" title="聚焦-" operateType="2" direct="2"/></div>\n                    <div class="ws-pan-tilt-control-item"><img src="${this.prefixUrl}/WSPlayer/icon/ptz-icon4.svg" title="聚焦+" operateType="2" direct="1"/></div>\n                    <div class="cloud-control-separate"></div>\n                    <div class="ws-pan-tilt-control-item"><img src="${this.prefixUrl}/WSPlayer/icon/ptz-icon5.svg" title="光圈-" operateType="3" direct="2"/></div>\n                    <div class="ws-pan-tilt-control-item"><img src="${this.prefixUrl}/WSPlayer/icon/ptz-icon6.svg" title="光圈+" operateType="3" direct="1"/></div>\n                </div>\n                \n                \x3c!--遮罩，当通道没有云台功能时，使用遮罩遮住云台按钮--\x3e\n                \x3c!--方向按钮遮罩--\x3e\n                <div class="ws-pan-tilt-mask ws-pan-tilt-mask-direction"></div>\n                \x3c!--三维定位遮罩--\x3e\n                <div class="ws-pan-tilt-mask ws-pan-tilt-mask-position"></div>\n                \x3c!--变倍、聚焦遮罩--\x3e\n                <div class="ws-pan-tilt-mask ws-pan-tilt-mask-zoom"></div>\n                \x3c!--光圈遮罩--\x3e\n                <div class="ws-pan-tilt-mask ws-pan-tilt-mask-aperture"></div>\n            </div>\n        `
			),
				$('.ws-pan-tilt-circle', this.$el).mouseup((e) => {
					if (this.clickDirectFlag) {
						this.clickDirectFlag = !1;
						let t = this.__getDirect(e.target);
						t && this.__setPtzDirection.call(this, t, '0');
					}
				}),
				$('.ws-pan-tilt-circle', this.$el).mouseout((e) => {
					if (this.clickDirectFlag) {
						this.clickDirectFlag = !1;
						let t = this.__getDirect(e.target);
						t && this.__setPtzDirection.call(this, t, '0');
					}
				}),
				$('.ws-pan-tilt-circle', this.$el).mousedown(
					this._throttle((e) => {
						if (!this.clickDirectFlag) {
							let t = this.__getDirect(e.target);
							t && ((this.clickDirectFlag = !0), this.__setPtzDirection.call(this, t, '1'));
						}
					}, 1e3)
				),
				$('.ws-pan-tilt-control-item img', this.$el).mouseup((e) => {
					this.__setPtzCamera(e.target.getAttribute('operateType'), e.target.getAttribute('direct'), '0');
				}),
				$('.ws-pan-tilt-control-item img', this.$el).mouseout((e) => {
					this.__setPtzCamera(e.target.getAttribute('operateType'), e.target.getAttribute('direct'), '0');
				}),
				$('.ws-pan-tilt-control-item img', this.$el).mousedown(
					this._throttle((e) => {
						this.__setPtzCamera(e.target.getAttribute('operateType'), e.target.getAttribute('direct'), '1');
					}, 1e3)
				),
				$('.ws-pan-tilt-pzt-select', this.$el).click((e) => {
					this.__openSitPosition(!this.openSitPositionFlag);
				});
		}
		__getDirect(e) {
			let t = e.getAttribute('direct');
			if (!t) {
				let s = e.childNodes[0];
				s && s.getAttribute && (t = s.getAttribute('direct'));
			}
			return t;
		}
		__setPtzDirection(e, t) {
			const s = {
				project: 'PSDK',
				method: 'DMS.Ptz.OperateDirect',
				data: { direct: e, command: t, stepX: '4', stepY: '4', channelId: this.channel.id },
			};
			if (
				(this.setPtzDirectionPromiseList.push(
					() =>
						new Promise((e, i) => {
							this.setPtzDirection &&
								this.setPtzDirection(s)
									.then((s) => {
										let i = s.data || s;
										'1' === t &&
											i.result &&
											'0' === i.result &&
											this.wsPlayer.sendErrorMessage(701, { insert: [s.data.lockUser.userName], apiErrorInfo: s }),
											e();
									})
									.catch((e) => {
										let s = [''];
										1103 === (e.data || e).code && (s = ['：您无权限进行此操作']),
											'1' === t && this.wsPlayer.sendErrorMessage(704, { apiErrorInfo: e, insert: s }),
											i();
									});
						})
				),
				!this.setPtzDirectionRun)
			) {
				let e = () => {
					(this.setPtzDirectionRun = !0),
						this.setPtzDirectionPromiseList[0]()
							.then(() => {})
							.catch(() => {})
							.finally(() => {
								this.setPtzDirectionPromiseList.shift(), this.setPtzDirectionPromiseList.length ? e() : (this.setPtzDirectionRun = !1);
							});
				};
				e();
			}
		}
		__setPtzCamera(e, t, s) {
			const i = {
				project: 'PSDK',
				method: 'DMS.Ptz.OperateCamera',
				data: { operateType: e, direct: t, command: s, step: '4', channelId: this.channel.id },
			};
			if (
				(this.setPtzCameraPromiseList.push(
					() =>
						new Promise((e, t) => {
							this.setPtzCamera &&
								this.setPtzCamera(i)
									.then((t) => {
										let i = t.data || t;
										'1' === s &&
											i.result &&
											'0' === i.result &&
											this.wsPlayer.sendErrorMessage(701, { insert: [t.data.lockUser.userName], apiErrorInfo: t }),
											e();
									})
									.catch((e) => {
										let a = ['', '变倍', '变焦', '光圈'],
											l = ['', '+', '-'],
											r = ['', '', ''];
										1103 === (e.data || e).code && (r = [a[i.data.operateType], l[i.data.direct], '：您无权限进行此操作']),
											'1' === s && this.wsPlayer.sendErrorMessage(703, { apiErrorInfo: e, insert: r }),
											t();
									});
						})
				),
				!this.setPtzCameraRun)
			) {
				let e = () => {
					(this.setPtzCameraRun = !0),
						this.setPtzCameraPromiseList[0]()
							.then(() => {})
							.catch(() => {})
							.finally(() => {
								this.setPtzCameraPromiseList.shift(), this.setPtzCameraPromiseList.length ? e() : (this.setPtzCameraRun = !1);
							});
				};
				e();
			}
		}
		__openSitPosition(e) {
			this.openSitPositionFlag = e;
			let t = this.wsPlayer.playerList,
				s = this.wsPlayer.selectIndex;
			(this.canvasElem = t[s].pztCanvasElem),
				this.canvasElem.addEventListener('mousedown', this.mousedownCanvasEvent),
				this.canvasElem.addEventListener('mousemove', this.mousemoveCanvasEvent),
				this.canvasElem.addEventListener('mouseup', this.mouseupCanvasEvent),
				(this.canvasContext = this.canvasElem.getContext('2d')),
				(this.canvasContext.lineWidth = 2),
				(this.canvasContext.strokeStyle = '#009cff'),
				this.openSitPositionFlag
					? ((this.channelCodeForPositionList[s] = this.channel.id),
						$(this.canvasElem).css({ display: 'block' }),
						$('.ws-pan-tilt-pzt-select', this.$el).attr({ src: `${this.prefixUrl}/WSPlayer/icon/ptz-select-hover.svg` }))
					: ((this.channelCodeForPositionList[s] = null),
						$(this.canvasElem).css({ display: 'none' }),
						$('.ws-pan-tilt-pzt-select', this.$el).attr({ src: `${this.prefixUrl}/WSPlayer/icon/ptz-select.svg` }));
		}
		__mousedownCanvasEvent(e) {
			e.target === this.canvasElem &&
				(e.offsetX || e.layerX) &&
				((this.pointX = e.offsetX || e.layerX), (this.pointY = e.offsetY || e.layerY), (this.startDraw = !0));
		}
		__mousemoveCanvasEvent(e) {
			if (e.target === this.canvasElem && this.startDraw && (e.offsetX || e.layerX)) {
				const t = e.offsetX || e.layerX,
					s = e.offsetY || e.layerY,
					i = t - this.pointX,
					a = s - this.pointY;
				this.canvasContext.clearRect(0, 0, this.canvasElem.width, this.canvasElem.height),
					this.canvasContext.beginPath(),
					this.canvasContext.strokeRect(this.pointX, this.pointY, i, a);
			}
		}
		__mouseupCanvasEvent(e) {
			if (e.target === this.canvasElem && (e.offsetX || e.layerX)) {
				this.startDraw = !1;
				const t = e.offsetX || e.layerX,
					s = e.offsetY || e.layerY;
				let i = '',
					a = '',
					l = '';
				const r = (t + this.pointX) / 2,
					n = (s + this.pointY) / 2,
					o = this.canvasElem.width / 2,
					d = this.canvasElem.height / 2,
					c = Math.abs(t - this.pointX),
					h = Math.abs(s - this.pointY),
					p = t < this.pointX;
				(i = (8192 * (r - o) * 2) / this.canvasElem.width),
					(a = (8192 * (n - d) * 2) / this.canvasElem.height),
					t === this.pointX || s === this.pointY ? (l = 0) : ((l = (this.canvasElem.width * this.canvasElem.height) / (c * h)), p && (l = -l)),
					this.canvasContext.clearRect(0, 0, this.canvasElem.width, this.canvasElem.height),
					this.__controlSitPosition(i, a, l);
			}
		}
		__removeCanvasEvent() {
			this.canvasElem &&
				(this.canvasElem.removeEventListener('mousedown', this.mousedownCanvasEvent),
				this.canvasElem.removeEventListener('mousemove', this.mousemoveCanvasEvent),
				this.canvasElem.removeEventListener('mouseup', this.mouseupCanvasEvent),
				$(this.canvasElem).css({ display: 'none' }),
				(this.canvasElem = null),
				(this.canvasContext = null),
				(this.openSitPositionFlag = !1),
				$('.ws-pan-tilt-pzt-select', this.$el).attr({ src: `${this.prefixUrl}/WSPlayer/icon/ptz-select.svg` }));
		}
		__controlSitPosition(e, t, s) {
			const i = {
				project: 'PSDK',
				method: 'DMS.Ptz.SitPosition',
				data: {
					magicId: localStorage.getItem('magicId') || '',
					pointX: String(Math.round(e)),
					pointY: String(Math.round(t)),
					pointZ: String(Math.round(s)),
					extend: '1',
					channelId: this.channel.id,
				},
			};
			this.controlSitPosition &&
				this.controlSitPosition(i)
					.then((e) => {
						let t = e.data || e;
						t.result && '0' === t.result && this.wsPlayer.sendErrorMessage(701, { insert: [e.data.lockUser.userName], apiErrorInfo: e });
					})
					.catch((e) => {
						let t = [''];
						1103 === (e.data || e).code && (t[0] = '：您无权限进行此操作'), this.wsPlayer.sendErrorMessage(702, { apiErrorInfo: e, insert: t });
					});
		}
		_throttle(e, t) {
			let s = 0;
			return function (...i) {
				const a = new Date().getTime();
				if (!(a - s < t)) return (s = a), e.apply(this, i);
			};
		}
	}
	const b = {
			num: 1,
			maxNum: 25,
			showControl: !0,
			draggable: !1,
			showRecordProgressBar: !0,
			isDynamicLoadLib: !0,
			onlyLoadSingleLib: !1,
			useNginxProxy: !1,
			openIvs: !0,
			ivsTypeArr: [1, 2],
			useH264MSE: !0,
			useH265MSE: !0,
			showIcons: { streamChangeSelect: !0, talkIcon: !0, localRecordIcon: !0, audioIcon: !0, snapshotIcon: !0, closeIcon: !0 },
			downloadMp4Record: !0,
			localRecordSize: 100,
			playCenterRecordByTime: !1,
		},
		D = 100,
		T = 100 / D;
	let k,
		C,
		E = 20,
		R = {},
		L = !0,
		M = '',
		_ = { x: 0, y: 0 },
		N = [],
		K = {},
		U = {},
		W = 0,
		B = '',
		A = () => {
			try {
				document.querySelector(k).onselectstart = function () {
					return !1;
				};
			} catch {
				setTimeout(() => {
					A();
				}, 200);
			}
		};
	function V(e = []) {
		if (!e.length || 1 === e.length) return (N = [{ wStep: D, hStep: D, tStep: 0, lStep: 0, selectIndex: 0 }]), N;
		e = e.sort((e, t) => e.tStep - t.tStep);
		for (let t = 0; t < e.length - 1; t++)
			if (e[t].tStep === e[t + 1].tStep && e[t].lStep > e[t + 1].lStep) {
				let s = { ...e[t] };
				(e[t] = { ...e[t + 1] }), (e[t + 1] = s);
			}
		return e.map((e, t) => ((e.selectIndex = t), e));
	}
	function z(e, t) {
		let s = document.querySelector('#temp-preview-line');
		(s.style.display = 'block'),
			(s.style.background = '#1d79f4'),
			(s.style.opacity = 0.4),
			'col' === t &&
				((s.style.left = `${Math.floor(e.lStep + e.wStep / 2)}%`),
				(s.style.top = `${e.tStep}%`),
				(s.style.width = '2px'),
				(s.style.height = `${e.hStep}%`)),
			'raw' === t &&
				((s.style.left = `${e.lStep}%`),
				(s.style.top = `${Math.floor(e.tStep + e.hStep / 2)}%`),
				(s.style.width = `${e.wStep}%`),
				(s.style.height = '2px'));
	}
	function F(e, t) {
		N.length !== E
			? (1 === e.wStep && 1 === e.hStep) ||
				('col' === t &&
					(N.push({ ...e, lStep: e.lStep + Math.floor(e.wStep / 2), wStep: Math.ceil(e.wStep / 2) }),
					(N[e.selectIndex] = { ...e, wStep: Math.floor(e.wStep / 2) })),
				'raw' === t &&
					(N.push({ ...e, tStep: e.tStep + Math.floor(e.hStep / 2), hStep: Math.ceil(e.hStep / 2) }),
					(N[e.selectIndex] = { ...e, hStep: Math.floor(e.hStep / 2) })),
				q())
			: R.onError(`自定义播放器只支持最大分割${E}个窗口`);
	}
	function O(e, t) {
		let s = '';
		return (
			'x' === t &&
				(s = `<div id="division-move-line" style="position: absolute; background: #1d79f4; top: ${e.tStep * T}%; left: ${e.lStep * T}%; width: 2px; height: ${e.hStep * T}%; "></div>`),
			'y' === t &&
				(s = `<div id="division-move-line" style="position: absolute; background: #1d79f4; top: ${e.tStep * T}%; left: ${e.lStep * T}%; width: ${e.wStep * T}%; height: 2px; "></div>`),
			s
		);
	}
	function H(e) {
		return `<div\n        id="dom-item-${e.selectIndex}"\n        class="${L ? 'dom-item-flex' : 'dom-item'}"\n        style="top: ${e.top}%; left: ${e.left}%; width: ${e.width}%; height: ${e.height}%;"\n    >\n        <div class="point-n-resize" id="dom-item-${e.selectIndex}-bottom-border" style="bottom: -4px; left: 0; width: 100%; height: 6px;"></div>\n        <div class="point-e-resize" id="dom-item-${e.selectIndex}-right-border" style="top: 0; right: -4px; width: 6px; height: 100%;"></div>\n        <div style="width: 68px; display: flex;">\n            <div id="dom-item-${e.selectIndex}-btn-col" class="dom-item-split-btn"></div>\n            <div id="dom-item-${e.selectIndex}-btn-raw" class="dom-item-split-btn" style="margin-left: 11px; transform: rotate(90deg)"></div>\n        </div>\n        <div id="dom-item-${e.selectIndex}-delete-btn" class="dom-item-merge-btn"></div>\n    </div>`;
	}
	function j(e = []) {
		L = !1;
		let t = [];
		e.forEach((e) => {
			t.push(H({ selectIndex: e.selectIndex, width: e.wStep * T, height: e.hStep * T, top: e.tStep * T, left: e.lStep * T }));
		}),
			(C.innerHTML = t.join('') + '<div id="temp-preview-line" style="position: absolute; z-index: 10; display: none;"></div>'),
			e.forEach((e) => {
				document.querySelector(`#dom-item-${e.selectIndex}-btn-raw`).addEventListener('click', () => {
					F(e, 'raw');
				}),
					document.querySelector(`#dom-item-${e.selectIndex}-btn-col`).addEventListener('click', () => {
						F(e, 'col');
					}),
					document.querySelector(`#dom-item-${e.selectIndex}-delete-btn`).addEventListener('click', () => {
						!(function (e) {
							if (1 === N.length) return void R.onError('当前窗口无法被合并');
							let t = N.findIndex(
								(t) =>
									(t.wStep === e.wStep && t.lStep === e.lStep && (t.tStep + t.hStep === e.tStep || e.tStep + e.hStep === t.tStep)) ||
									(t.hStep === e.hStep && t.tStep === e.tStep && (t.lStep + t.wStep === e.lStep || e.lStep + e.wStep === t.lStep))
							);
							if (t > -1) {
								let s = N[t];
								s.tStep === e.tStep &&
									(s.selectIndex > e.selectIndex
										? ((N[e.selectIndex].wStep = e.wStep + s.wStep), N.splice(s.selectIndex, 1))
										: ((N[s.selectIndex].wStep = s.wStep + e.wStep), N.splice(e.selectIndex, 1))),
									s.lStep === e.lStep &&
										(s.selectIndex > e.selectIndex
											? ((N[e.selectIndex].hStep = e.hStep + s.hStep), N.splice(s.selectIndex, 1))
											: ((N[s.selectIndex].hStep = s.hStep + e.hStep), N.splice(e.selectIndex, 1)));
							} else R.onError('当前窗口无法被合并');
							q();
						})(e);
					}),
					document.querySelector(`#dom-item-${e.selectIndex}-btn-raw`).addEventListener('mouseenter', (t) => {
						z(e, 'raw');
					}),
					document.querySelector(`#dom-item-${e.selectIndex}-btn-raw`).addEventListener('mouseleave', (e) => {
						document.querySelector('#temp-preview-line').style.display = 'none';
					}),
					document.querySelector(`#dom-item-${e.selectIndex}-btn-col`).addEventListener('mouseenter', (t) => {
						z(e, 'col');
					}),
					document.querySelector(`#dom-item-${e.selectIndex}-btn-col`).addEventListener('mouseleave', (e) => {
						document.querySelector('#temp-preview-line').style.display = 'none';
					}),
					document.querySelector(`#dom-item-${e.selectIndex}-right-border`).addEventListener('mousedown', (t) => {
						e.lStep + e.wStep !== D &&
							((M = 'right-border'),
							(_ = { x: 0 }),
							(W = 0),
							(K = (function ({ wStep: e, lStep: t, selectIndex: s }, i) {
								let a = i.filter((s) => s.lStep + s.wStep === t + e).sort((e, t) => e.tStep - t.tStep),
									l = i.filter((s) => s.lStep === t + e).sort((e, t) => e.tStep - t.tStep);
								for (var r = 0; r < a.length - 1; r++)
									a[r].tStep + a[r].hStep !== a[r + 1].tStep && (s <= a[r].selectIndex ? a.splice(r + 1) : (a.splice(0, r), (r = -1)));
								let n = -1,
									o = -1;
								return (
									l.forEach((e) => {
										let t = a.findIndex((t) => e.tStep === t.tStep),
											s = a.findLastIndex((t) => e.tStep + e.hStep === t.tStep + t.hStep);
										t > -1 && (n = 0 === t ? 0 : Math.min(t, n)), s > -1 && (o = Math.max(s, o));
									}),
									(l = l.filter((e) => e.tStep >= a[n].tStep && e.tStep + e.hStep <= a[o].tStep + a[o].hStep)),
									{ l_window: l, r_window: a }
								);
							})({ ...e }, JSON.parse(JSON.stringify(N)))),
							(U = { hStep: K.r_window.reduce((e, t) => e + t.hStep, 0), tStep: K.r_window[0].tStep, lStep: K.l_window[0].lStep }),
							(B = O(U, 'x')),
							(C.innerHTML += B));
					}),
					document.querySelector(`#dom-item-${e.selectIndex}-bottom-border`).addEventListener('mousedown', (t) => {
						e.tStep + e.hStep !== D &&
							((M = 'bottom-border'),
							(_ = { y: 0 }),
							(W = 0),
							(K = (function ({ hStep: e, tStep: t, selectIndex: s }, i) {
								let a = i.filter((s) => s.tStep + s.hStep === t + e).sort((e, t) => e.lStep - t.lStep),
									l = i.filter((s) => s.tStep === t + e).sort((e, t) => e.lStep - t.lStep);
								for (var r = 0; r < a.length - 1; r++)
									a[r].lStep + a[r].wStep !== a[r + 1].lStep && (s <= a[r].selectIndex ? a.splice(r + 1) : (a.splice(0, r), (r = -1)));
								let n = -1,
									o = -1;
								return (
									l.forEach((e) => {
										let t = a.findIndex((t) => e.lStep === t.lStep),
											s = a.findLastIndex((t) => e.lStep + e.wStep === t.lStep + t.wStep);
										t > -1 && (n = 0 === t ? 0 : Math.min(t, n)), s > -1 && (o = Math.max(s, o));
									}),
									(l = l.filter((e) => e.lStep >= a[n].lStep && e.lStep + e.wStep <= a[o].lStep + a[o].wStep)),
									{ t_window: l, b_window: a }
								);
							})({ ...e }, JSON.parse(JSON.stringify(N)))),
							(U = { wStep: K.b_window.reduce((e, t) => e + t.wStep, 0), lStep: K.b_window[0].lStep, tStep: K.t_window[0].tStep }),
							(B = O(U, 'y')),
							(C.innerHTML += B));
					});
			});
	}
	function q() {
		(C.innerHTML = ''), (N = V(N)), j(N);
	}
	A(),
		document.addEventListener('mousemove', (e) => {
			if (!M) return;
			let t = C.getBoundingClientRect(),
				s = t.width / D,
				i = t.height / D;
			switch (M) {
				case 'right-border':
					if (((_.x += e.movementX), W !== Math.round(_.x / s))) {
						if (((W = Math.round(_.x / s)), U.lStep + W <= 0)) return void (W = 1 - U.lStep);
						if (U.lStep + W >= D) return void (W = D - U.lStep - 1);
						document.querySelector('#division-move-line').style.left = (U.lStep + W) * T + '%';
					}
					break;
				case 'bottom-border':
					if (((_.y += e.movementY), W !== Math.round(_.y / i))) {
						if (((W = Math.round(_.y / i)), U.tStep + W <= 0)) return void (W = 1 - U.tStep);
						U.tStep + W >= D && (W = D - U.tStep - 1), (document.querySelector('#division-move-line').style.top = (U.tStep + W) * T + '%');
					}
			}
		}),
		document.addEventListener('mouseup', (e) => {
			if (M) {
				let e = [],
					t = !0;
				switch (M) {
					case 'right-border':
						if (!W) return;
						let { l_window: s, r_window: i } = K;
						if (
							((e = [
								...s.map((e) => ((e.wStep -= W), (e.lStep += W), e.wStep < 1 && (t = !1), e)),
								...i.map((e) => ((e.wStep += W), e.wStep < 1 && (t = !1), e)),
							]),
							!t)
						)
							return (M = ''), document.querySelector('#division-move-line').remove(), q(), void R.onError('不能拖拽到当前位置，请重新拖拽');
						e.forEach((e) => (N[e.selectIndex] = e));
						break;
					case 'bottom-border':
						if (!W) return;
						let { t_window: a, b_window: l } = K;
						if (
							((e = [
								...a.map((e) => ((e.hStep -= W), (e.tStep += W), e.hStep < 1 && (t = !1), e)),
								...l.map((e) => ((e.hStep += W), e.hStep < 1 && (t = !1), e)),
							]),
							!t)
						)
							return (M = ''), document.querySelector('#division-move-line').remove(), q(), void R.onError('不能拖拽到当前位置，请重新拖拽');
						e.forEach((e) => (N[e.selectIndex] = e));
				}
				(M = ''), q();
			}
		});
	const X = (e) => {
			let { division: t, windowId: s, callback: i, maxNum: a } = e;
			if (
				((E = a),
				(k = document.querySelector(`#${s}`)),
				(k.innerHTML = (function (e) {
					return `<div id="${e}-container" style="width: 100%; height: 100%; border: 1px solid #aaa; position: relative;"></div>\n        <div class="window-division-bottom-container">\n            <button class="window-division-btn window-division-btn-primary" id="${e}-confirm-btn">确认</button>\n            <button class="window-division-btn window-division-btn-info" id="${e}-cancel-btn">取消</button>\n        </div>\n    `;
				})(s)),
				(C = document.querySelector(`#${s}-container`)),
				(R = i),
				document.querySelector(`#${s}-confirm-btn`).addEventListener('click', () => {
					i.onConfirm && i.onConfirm(JSON.stringify(N));
				}),
				document.querySelector(`#${s}-cancel-btn`).addEventListener('click', () => {
					i.onCancel && i.onCancel();
				}),
				t)
			)
				if ([1, 4, 9, 16, 25].includes(Number(t)))
					!(function (e = 4) {
						L = !0;
						let t = [],
							s = 100 / Math.sqrt(e);
						for (var i = 0; i < e; i++) t.push({ selectIndex: i, width: s, height: s });
						var a = t.map((e) => H(e));
						C.innerHTML = a.join('');
					})(Number(t));
				else if ('string' != typeof t) i.onError && i.onError('传入格式错误，请重新传入');
				else
					try {
						(N = V(JSON.parse(t))), j(N);
					} catch (l) {
						i.onError && i.onError('传入格式错误，请重新传入');
					}
			else j(V());
		},
		J = { selfAdaption: '自适应', stretching: '拉伸' };
	class Y {
		constructor(e) {
			if (!e.type) return console.error('type 为必传参数，请校验入参'), !1;
			if (
				((this.options = e),
				(this.type = e.type),
				(this.config = i.mergeObject(b, e.config)),
				(this.setWSUrl = e.setWSUrl),
				(this.WS_TIMEOUT = e.WS_TIMEOUT || 1),
				(this.wsProtocol = e.protocol),
				(this.isIntranet = e.isIntranet),
				(this.intranetMap = e.intranetMap),
				(this.proxyServerIp = e.proxyServerIp || e.serverIp),
				(this.streamServerIp = e.streamServerIp || e.serverIp),
				(this.prefixUrl = e.prefixUrl || './static'),
				(this.rtspResponseTimeout = e.rtspResponseTimeout - 0),
				(this.procedure = new I({
					type: this.type,
					player: this,
					playCenterRecordByTime: this.config.playCenterRecordByTime,
					getRealRtsp: e.getRealRtsp,
					getRecords: e.getRecords,
					getRecordRtspByTime: e.getRecordRtspByTime,
					getRecordRtspByFile: e.getRecordRtspByFile,
					getTalkRtsp: e.getTalkRtsp,
					stopTalk: e.stopTalk,
				})),
				e.pztEl && this.initPanTilt(e),
				(this.sendMessage = e.receiveMessageFromWSPlayer || function (e, t, s) {}),
				(this.el = e.el),
				(this.fetchChannelAuthority = e.getChannelAuthority),
				(this.$el = $('#' + this.el)),
				this.$el.empty(),
				!this.$el.length)
			)
				return void this.sendErrorMessage(503);
			(this.width = this.$el.attr('width')),
				(this.height = this.$el.attr('height')),
				this.$el.height(`${this.height}px`),
				this.$el.width(`${this.width}px`),
				this.$el.addClass('ws-player'),
				this.$el.append('<div class="player-wrapper"></div>'),
				(this.$wrapper = $('.player-wrapper', this.$el)),
				(this.playerList = []),
				(this.playerAdapter = 'selfAdaption'),
				(this.canvas = {}),
				(this.ctx = {}),
				(this.showNum = 1),
				(this.maxWindow = 1),
				$(this.$el).attr('inited', !0);
			let { isVersionCompliance: t, browserType: s, errorCode: a } = i.checkBrowser();
			switch (
				((this.isHttps = 'https:' === location.protocol),
				this.config.isDynamicLoadLib && this.loadLibPlay(t),
				this.setMaxWindow(),
				(this.currentDragWindowIndex = -1),
				(this.beforeShowNum = 1),
				this.type)
			) {
				case 'real':
					this.createRealPlayer(e);
					break;
				case 'record':
					this.createRecordPlayer(e);
			}
			this.setSelectIndex(0),
				this.setPlayerNum(this.config.division || this.config.num),
				this.setCanvasGetContext(),
				(this.bindUpdatePlayerWindow = this.__updatePlayerWindow.bind(this)),
				window.addEventListener('resize', this.bindUpdatePlayerWindow),
				window.wsPlayerManager || (window.wsPlayerManager = new w()),
				this.__updateTopBarStyle();
		}
		setCanvasGetContext() {
			var e;
			window.wsCanvasGetContextSet ||
				((window.wsCanvasGetContextSet = !0),
				(HTMLCanvasElement.prototype.getContext =
					((e = HTMLCanvasElement.prototype.getContext),
					function (t, s) {
						return 'webgl' === t && (s = Object.assign({}, s, { preserveDrawingBuffer: !0 })), e.call(this, t, s);
					})));
		}
		setMaxWindow() {
			let e = parseInt(this.config.maxNum, 10);
			this.maxWindow = e > 16 ? 25 : e > 9 ? 16 : e > 8 ? 9 : e > 6 ? 8 : e > 4 ? 6 : e;
		}
		createRealPlayer() {
			this.config.showControl ? this.__addRealControl() : this.$wrapper.addClass('nocontrol'),
				Array(this.maxWindow)
					.fill(1)
					.forEach((e, t) => {
						let s = new y({ wrapperDomId: this.el, index: t, wsPlayer: this });
						this.playerList.push(s);
					});
		}
		createRecordPlayer() {
			this.config.showRecordProgressBar && this.__addRecordControl(),
				this.config.showControl && this.__addRealControl(),
				!this.config.showRecordProgressBar && !this.config.showControl && this.$wrapper.addClass('nocontrol'),
				Array(this.maxWindow)
					.fill(1)
					.forEach((e, t) => {
						let s = new u({ wrapperDomId: this.el, index: t, wsPlayer: this });
						this.playerList.push(s);
					});
		}
		loadScript(e, t) {
			let s = document.createElement('script');
			(s.src = e), document.head.appendChild(s);
			var i = !1;
			'function' == typeof t &&
				(s.onload = s.onreadystatechange =
					function () {
						i || (s.readyState && !/loaded|complete/.test(s.readyState)) || ((s.onload = s.onreadystatechange = null), (i = !0), t());
					});
		}
		loadLibPlay(e) {
			let t = this;
			if (window.loadLibPlayerFlag)
				return (
					(this.config.onlyLoadSingleLib = window.onlyLoadSingleLib),
					void setTimeout(() => {
						t.sendMessage('initializationCompleted');
					}, 300)
				);
			if (
				((window.loadLibPlayerFlag = !0),
				(window.m_bClientInitialized = !1),
				window.Module || (window.Module = {}),
				(Module.onRuntimeInitialized = function () {
					setTimeout(() => {
						(window.m_nModuleInitialized = !0), t.sendMessage('initializationCompleted');
					}, 300);
				}),
				(Module.locateFile = function (e, s) {
					return e.endsWith('.data') ? `${t.prefixUrl}/WSPlayer/multiThread/libplay.data` : s + e;
				}),
				!this.isHttps || !e || this.config.onlyLoadSingleLib)
			)
				return (
					this.loadLibRenderEngine(),
					this.loadLibIVSDrawer(),
					(this.config.onlyLoadSingleLib = !0),
					(window.onlyLoadSingleLib = this.config.onlyLoadSingleLib),
					void setTimeout(() => {
						(window.m_nModuleInitialized = !0), this.sendMessage('initializationCompleted');
					}, 300)
				);
			try {
				new SharedArrayBuffer(1), this.loadLibPlaySDK(), this.loadLibStreamClient();
			} catch (s) {
				this.loadLibRenderEngine(),
					this.loadLibIVSDrawer(),
					(this.config.onlyLoadSingleLib = !0),
					(window.onlyLoadSingleLib = this.config.onlyLoadSingleLib),
					setTimeout(() => {
						(window.m_nModuleInitialized = !0), this.sendMessage('initializationCompleted');
					}, 300);
			}
		}
		loadLibPlaySDK() {
			let e = `${this.prefixUrl}/WSPlayer/multiThread/libplay.js`;
			this.loadScript(e, null);
		}
		loadLibStreamClient() {
			let e = `${this.prefixUrl}/WSPlayer/multiThread/libStreamClient.js`;
			this.loadScript(e, function () {
				Multi_Client_Module().then((e) => {
					(window.SCModule = e), window.SCModule._GLOBAL_Init(), (window.m_bClientInitialized = !0);
				});
			});
		}
		loadLibRenderEngine() {
			let e = `${this.prefixUrl}/WSPlayer/singleThread/libRenderEngine.js`;
			this.loadScript(e, function () {
				RenderEngine_Module().then((e) => {
					window.REModule = e;
				});
			});
		}
		loadLibIVSDrawer() {
			let e = `${this.prefixUrl}/WSPlayer/singleThread/libIVSDrawer.js`;
			this.loadScript(e, function () {
				IVSDrawer_Module().then((e) => {
					window.IVSModule = e;
				});
			});
		}
		playReal(e) {
			this.__getWSUrl(e).then((t) => {
				(e.wsURL = e.wsURL || t), (e.playerAdapter = e.playerAdapter || this.playerAdapter);
				let s = this.playerList[e.selectIndex];
				(s.playType = e.playType),
					e.selectIndex + 1 < this.showNum
						? this.setSelectIndex(e.selectIndex + 1)
						: this.selectIndex === e.selectIndex && s && this.setPtzChannel(e.channelData),
					s && s.init(e);
			});
		}
		playRecord(e, t = {}) {
			return new Promise((s) => {
				let i = this.playerList[e.selectIndex];
				(i.playType = e.playType),
					this.__getWSUrl(e).then((a) => {
						(e.wsURL = e.wsURL || a),
							(e.playerAdapter = e.playerAdapter || this.playerAdapter),
							(e.isPlayback = !0),
							e.selectIndex + 1 < this.showNum && !e.isJumpPlay
								? this.setSelectIndex(e.selectIndex + 1)
								: ($('.ws-record-play', this.$el).css({ display: 'none' }), $('.ws-record-pause', this.$el).css({ display: 'block' }));
						for (let e in t) i[e] = t[e];
						i && i.init(e), s();
					});
			});
		}
		openVolume(e) {
			let t = this.playerList[void 0 === e ? this.selectIndex : e];
			!t.isAudioPlay && t.openVolume();
		}
		closeVolume(e) {
			let t = this.playerList[void 0 === e ? this.selectIndex : e];
			t.isAudioPlay && t.closeVolume();
		}
		setVolume(e, t) {
			let s = this.playerList[void 0 === e ? this.selectIndex : e];
			t > 0 ? s.openVolume(t) : s.closeVolume();
		}
		picCap(e, t) {
			this.playerList[void 0 === e ? this.selectIndex : e].picCap(t);
		}
		play(e) {
			if ('real' === this.type) return void this.sendErrorMessage(611, { method: 'play', arguments: { index: e } });
			let t = this.playerList[void 0 === e ? this.selectIndex : e];
			t ? 'pause' === t.status && t.play() : this.sendErrorMessage(601, { method: 'play', arguments: { index: e } });
		}
		pause(e) {
			if ('real' === this.type) return void this.sendErrorMessage(612, { method: 'pause', arguments: { index: e } });
			let t = this.playerList[void 0 === e ? this.selectIndex : e];
			t ? 'playing' === t.status && t.pause() : this.sendErrorMessage(601, { method: 'pause', arguments: { index: e } });
		}
		playSpeed(e, t) {
			if ('real' === this.type) return void this.sendErrorMessage(607, { method: 'playSpeed', arguments: { speed: e, index: t } });
			let s = this.playerList[void 0 === t ? this.selectIndex : t];
			s ? s.playSpeed(parseFloat(e)) : this.sendErrorMessage(601, { method: 'playSpeed', arguments: { speed: e, index: t } });
		}
		setSelectIndex(e) {
			if (this.selectIndex === e || void 0 === e) return;
			let t = this.playerList[e];
			if (t) {
				if ((this.procedure && this.procedure.setPlayIndex(e), 'record' === this.type)) {
					let s = t.status;
					'playing' === s
						? ($('.ws-record-play', this.$el).css({ display: 'none' }), $('.ws-record-pause', this.$el).css({ display: 'block' }))
						: 'pause' === s && ($('.ws-record-pause', this.$el).css({ display: 'none' }), $('.ws-record-play', this.$el).css({ display: 'block' })),
						['playing', 'pause'].includes(s)
							? this.setTimeLine(t.options.recordList)
							: (this.setTimeLine([]),
								$('.ws-record-pause', this.$el).css({ display: 'none' }),
								$('.ws-record-play', this.$el).css({ display: 'block' })),
						this.__setPlaySpeed('', e);
				}
				this.sendMessage('selectWindowChanged', { channelId: (t.options || {}).channelId, playIndex: e }),
					(this.selectIndex = e),
					this.setPtzChannel((t.options || {}).channelData),
					this.playerList.forEach((t, s) => {
						s === e ? t.$el.removeClass('unselected').addClass('selected') : t.$el.removeClass('selected').addClass('unselected');
					});
			} else this.sendErrorMessage(601, { method: 'setSelectIndex', arguments: { index: e } });
		}
		createCustomDialog() {
			let e = `<div id="${this.el}-custom-container" class="custom-division-container"></div>`;
			this.$el.append(e),
				X({
					maxNum: this.config.maxNum,
					division: localStorage.customDivision || '',
					windowId: `${this.el}-custom-container`,
					callback: {
						onError: (e) => {
							this.sendErrorMessage(610, { mtehod: 'customDivisionError', arguments: {}, insert: [e] });
						},
						onConfirm: (e) => {
							(localStorage.customDivision = e), $(`#${this.el}-custom-container`).remove(), this.setCustomPlayer(e);
						},
						onCancel: () => {
							$(`#${this.el}-custom-container`).remove();
						},
					},
				});
		}
		numberToList(e) {
			let t = 100 / e,
				s = [];
			for (var i = 0; i < e; i++) for (var a = 0; a < e; a++) s.push({ lStep: a * t, tStep: i * t, wStep: t, hStep: t });
			return s;
		}
		renderPlayerNum(e, t) {
			let s = [];
			s = 'number' == typeof t ? this.numberToList(t) : t;
			let i = 100;
			for (var a = 0; a < e.length; a++) {
				let t = e[a].getAttribute('id'),
					l = t.split('-'),
					r = Number(l[l.length - 1]);
				s[r]
					? $(`#${t}`).css({
							top: `${s[r].tStep}%`,
							left: `${s[r].lStep}%`,
							width: `${s[r].wStep}%`,
							height: `${s[r].hStep}%`,
							visibility: 'visible',
							'z-index': i--,
						})
					: $(`#${t}`).css({ top: '150%', left: 0, width: 0, height: 0, visibility: 'hidden' });
			}
		}
		resetPlayerScreen(e, t) {
			for (let s = 0; s < t; s++) e[s] && $(`#${e[s].getAttribute('id')}`).css({ top: '150%', left: 0, width: 0, height: 0, visibility: 'hidden' });
		}
		setPlayerNum(e, t) {
			switch (typeof e) {
				case 'number':
					this.setDefaultPlayer(e, t);
					break;
				case 'string':
					this.setCustomPlayer(e, t);
			}
		}
		setDefaultPlayer(e, s) {
			let i = $(`#${this.el} .wsplayer-item`);
			this.resetPlayerScreen(i, this.config.maxNum);
			let a = parseInt(e) || 1;
			switch (a) {
				case 1:
					(a = 1), this.renderPlayerNum(i, 1);
					break;
				case 2:
					(a = JSON.stringify(t.windowDefaultCustomDivision[2])), this.renderPlayerNum(i, t.windowDefaultCustomDivision[2]);
					break;
				case 3:
					(a = JSON.stringify(t.windowDefaultCustomDivision[3])), this.renderPlayerNum(i, t.windowDefaultCustomDivision[3]);
					break;
				case 4:
					(a = 4), this.renderPlayerNum(i, 2);
					break;
				case 5:
				case 6:
					(a = JSON.stringify(t.windowDefaultCustomDivision[6])), this.renderPlayerNum(i, t.windowDefaultCustomDivision[6]);
					break;
				case 7:
				case 8:
					(a = JSON.stringify(t.windowDefaultCustomDivision[8])), this.renderPlayerNum(i, t.windowDefaultCustomDivision[8]);
					break;
				case 9:
					(a = 9), this.renderPlayerNum(i, 3);
					break;
				case 10:
				case 11:
				case 12:
				case 13:
				case 14:
				case 15:
				case 16:
					(a = 16), this.renderPlayerNum(i, 4);
					break;
				case 17:
				case 18:
				case 19:
				case 20:
				case 21:
				case 22:
				case 23:
				case 24:
				case 25:
					(a = 25), this.renderPlayerNum(i, 5);
			}
			a > this.maxWindow && (a = this.maxWindow),
				this.showNum !== a &&
					((this.showNum = a),
					!s && this.sendMessage('windowNumChanged', this.showNum),
					setTimeout(() => {
						this.__updatePlayerWindow();
					}, 200));
		}
		setCustomPlayer(e, t) {
			let s = $(`#${this.el} .wsplayer-item`);
			this.resetPlayerScreen(s, this.config.maxNum),
				this.renderPlayerNum(s, JSON.parse(e)),
				(this.showNum = e),
				!t && this.sendMessage('windowNumChanged', this.showNum),
				setTimeout(() => {
					this.__updatePlayerWindow();
				}, 200);
		}
		switchPlayerScreen(e, t, s) {
			$(`#${this.el}-${t}`).css({ top: `${e[s].tStep}%`, left: `${e[s].lStep}%`, width: `${e[s].wStep}%`, height: `${e[s].hStep}%` }),
				$(`#${this.el}-${s}`).css({ top: `${e[t].tStep}%`, left: `${e[t].lStep}%`, width: `${e[t].wStep}%`, height: `${e[t].hStep}%` });
			let i = $(`#${this.el}-${t} .default-status`).css('transform'),
				a = $(`#${this.el}-${s} .default-status`).css('transform');
			$(`#${this.el}-${t} .default-status`).css({ transform: a }),
				$(`#${this.el}-${s} .default-status`).css({ transform: i }),
				$(`#${this.el}-${t}`).attr('id', `${this.el}-temp`),
				$(`#${this.el}-${s}`).attr('id', `${this.el}-${t}`).removeClass(`wsplayer-item-${s}`).addClass(`wsplayer-item-${t}`),
				$(`#${this.el}-temp`).attr('id', `${this.el}-${s}`).removeClass(`wsplayer-item-${t}`).addClass(`wsplayer-item-${s}`);
			let l = this.playerList[t];
			(this.playerList[t] = this.playerList[s]),
				(this.playerList[s] = l),
				(this.playerList[t].index = t),
				(this.playerList[t].currentIndex = t),
				(this.playerList[t].domId = `${this.el}-${s}`),
				(this.playerList[s].index = s),
				(this.playerList[s].currentIndex = s),
				(this.playerList[s].domId = `${this.el}-${t}`);
		}
		changeDragWindow(e) {
			if (this.currentDragWindowIndex < 0 || this.currentDragWindowIndex === e) return void (this.currentDragWindowIndex = -1);
			let t = [];
			(t = 'number' == typeof this.showNum ? this.numberToList(Math.sqrt(this.showNum)) : JSON.parse(this.showNum)),
				this.switchPlayerScreen(t, this.currentDragWindowIndex, e),
				this.sendMessage('dragWindow', { dragIndex: this.currentDragWindowIndex, dropIndex: e }),
				this.currentDragWindowIndex === this.selectIndex && this.setSelectIndex(e),
				(this.currentDragWindowIndex = -1),
				setTimeout(() => {
					this.__updatePlayerWindow();
				}, 200);
		}
		setPlayerAdapter(e) {
			this.playerAdapter !== e &&
				(['selfAdaption', 'stretching'].includes(e)
					? ((this.playerAdapter = e), $('.ws-select-show-option', this.$el).text(J[e]), this.__updatePlayerWindow())
					: this.sendErrorMessage(606, { method: 'setPlayerAdapter', arguments: { playerAdapter: e } }));
		}
		setTimeLine(e = []) {
			this.config.showRecordProgressBar &&
				((this.timeList = e),
				this.timeList.length
					? $('#ws-record-time-box', this.$el).css({ visibility: 'visible' })
					: $('#ws-record-time-box', this.$el).css({ visibility: 'hidden' }),
				this.__setTimeRecordArea(e));
		}
		setFullScreen() {
			let e = this.$el[0].children[0];
			e.requestFullscreen
				? e.requestFullscreen()
				: e.webkitRequestFullscreen
					? e.webkitRequestFullscreen()
					: e.mozRequestFullScreen
						? e.mozRequestFullScreen()
						: e.msRequestFullscreen && e.msRequestFullscreen(),
				this.__updatePlayerWindow();
		}
		close(e) {
			let t = Number(e);
			if (isNaN(t))
				return void this.playerList.forEach((e) => {
					e.close();
				});
			let s = this.playerList[t];
			s && s.close();
		}
		destroy() {
			this.close(), window.removeEventListener('resize', this.bindUpdatePlayerWindow);
		}
		__addRealControl() {
			this.$el.append(
				`\n            <div class="ws-control">\n                <div class="ws-flex ws-control-record ws-flex-left">\n                    <div class="ws-ctrl-record-icon ws-record-play" style="display: none" title="播放"></div>\n                    <div class="ws-ctrl-record-icon ws-record-pause" title="暂停"></div>\n                    <div class="ws-ctrl-record-icon ws-record-speed-sub" title="倍速-"></div>\n                    <div class="ws-ctrl-record-icon ws-record-speed-txt">1x</div>\n                    <div class="ws-ctrl-record-icon ws-record-speed-add" title="倍速+"></div>\n                </div>\n                <div class="ws-flex ws-flex-end">\n                    <div class="ws-select-self-adaption">\n                        <div class="ws-select-show select">\n                            <div class="ws-select-show-option">自适应</div>\n                            \x3c!-- 下拉箭头 --\x3e\n                            <img src="${this.prefixUrl}/WSPlayer/icon/spread.png" />\n                        </div>\n                        <div class="ws-self-adaption-type" style="display: none">\n                            <ul class="ws-select-ul">\n                                <li optionValue="自适应" value="selfAdaption" class="ws-select-type-item">自适应</li>\n                                <li optionValue="拉伸" value="stretching" class="ws-select-type-item">拉伸</li>\n                            </ul>\n                        </div>\n                    </div>\n                    <span class="ws-ctrl-btn-spread ws-ctrl-btn-spread-1"></span>\n                    <div class="ws-ctrl-icon one-screen-icon" title="单屏"></div>\n                    <div class="ws-ctrl-icon two-screen-icon" title="2分屏"></div>\n                    <div class="ws-ctrl-icon four-screen-icon" title="4分屏"></div>\n                    <div class="ws-ctrl-icon nine-screen-icon" title="9分屏"></div>\n                    <div class="ws-ctrl-icon sixteen-screen-icon" title="16分屏"></div>\n                    <div class="ws-ctrl-icon twenty-five-screen-icon" title="25分屏"></div>\n                    <div class="ws-ctrl-icon three-screen-icon" title="3分屏"></div>\n                    <div class="ws-ctrl-icon six-screen-icon" title="6分屏"></div>\n                    <div class="ws-ctrl-icon eight-screen-icon" title="8分屏"></div>\n                    <div class="ws-ctrl-icon custom-screen-icon" title="自定义分屏"></div>\n                    <span class="ws-ctrl-btn-spread ws-ctrl-btn-spread-2"></span>\n                    <div class="ws-ctrl-icon close-all-video" title="一键关闭"></div>\n                    <div class="ws-ctrl-icon full-screen-icon" title="全屏"></div>\n                </div>\n            </div>\n        `
			),
				this.maxWindow <= 16 && $('.twenty-five-screen-icon', this.$el).css({ display: 'none' }),
				this.maxWindow <= 9 && $('.sixteen-screen-icon', this.$el).css({ display: 'none' }),
				this.maxWindow <= 8 && $('.nine-screen-icon', this.$el).css({ display: 'none' }),
				this.maxWindow <= 6 && $('.eight-screen-icon', this.$el).css({ display: 'none' }),
				this.maxWindow <= 4 && $('.six-screen-icon', this.$el).css({ display: 'none' }),
				this.maxWindow <= 3 && $('.four-screen-icon', this.$el).css({ display: 'none' }),
				this.maxWindow <= 2 && $('.three-screen-icon', this.$el).css({ display: 'none' }),
				1 === this.maxWindow &&
					($('.two-screen-icon', this.$el).css({ display: 'none' }),
					$('.one-screen-icon', this.$el).css({ display: 'none' }),
					$('.custom-screen-icon', this.$el).css({ display: 'none' }),
					$('.ws-ctrl-btn-spread-2', this.$el).css({ display: 'none' })),
				$('.full-screen-icon', this.$el).click(() => {
					this.setFullScreen();
				}),
				$('.one-screen-icon', this.$el).click(() => {
					this.setPlayerNum(1);
				}),
				$('.two-screen-icon', this.$el).click(() => {
					this.setPlayerNum(2);
				}),
				$('.three-screen-icon', this.$el).click(() => {
					this.setPlayerNum(3);
				}),
				$('.four-screen-icon', this.$el).click(() => {
					this.setPlayerNum(4);
				}),
				$('.six-screen-icon', this.$el).click(() => {
					this.setPlayerNum(6);
				}),
				$('.eight-screen-icon', this.$el).click(() => {
					this.setPlayerNum(8);
				}),
				$('.nine-screen-icon', this.$el).click(() => {
					this.setPlayerNum(9);
				}),
				$('.sixteen-screen-icon', this.$el).click(() => {
					this.setPlayerNum(16);
				}),
				$('.twenty-five-screen-icon', this.$el).click(() => {
					this.setPlayerNum(25);
				}),
				$('.close-all-video', this.$el).click(() => {
					this.close();
				}),
				$('.custom-screen-icon', this.$el).click(() => {
					this.createCustomDialog();
				}),
				(this.selfAdaptionSelectShow = !1),
				$('.ws-select-self-adaption', this.$el).click((e) => {
					this.selfAdaptionSelectShow
						? ($('.ws-self-adaption-type', this.$el).hide(), (this.selfAdaptionSelectShow = !1))
						: ($('.ws-self-adaption-type', this.$el).show(),
							(this.selfAdaptionSelectShow = !0),
							$('.ws-select-ul .ws-select-type-item', this.$el).css({ background: 'none' }),
							$(`.ws-select-ul [value=${this.playerAdapter}]`, this.$el).css({ background: '#1A78EA' }));
				}),
				$('.ws-self-adaption-type', this.$el).click((e) => {
					let t = e.target.getAttribute('value');
					this.setPlayerAdapter(t), $('.ws-select-show-option', this.$el).text(J[t]);
				}),
				'record' !== this.type && $('.ws-control-record', this.$el).css({ display: 'none' }),
				$('.ws-record-pause', this.$el).click((e) => {
					this.pause();
				}),
				$('.ws-record-play', this.$el).click((e) => {
					this.play();
				}),
				$('.ws-record-speed-sub', this.$el).click((e) => {
					'playing' === this.playerList[this.selectIndex].status && this.__setPlaySpeed('PREV');
				}),
				$('.ws-record-speed-add', this.$el).click((e) => {
					'playing' === this.playerList[this.selectIndex].status && this.__setPlaySpeed('NEXT');
				});
		}
		__setPlaySpeed(e, t) {
			let s,
				i,
				a = [
					{ value: 0.125, label: '0.125x' },
					{ value: 0.25, label: '0.25x' },
					{ value: 0.5, label: '0.5x' },
					{ value: 1, label: '1x' },
					{ value: 1.25, label: '1.25x' },
					{ value: 1.5, label: '1.5x' },
					{ value: 2, label: '2x' },
					{ value: 4, label: '4x' },
					{ value: 8, label: '8x' },
				],
				l = this.playerList[void 0 === t ? this.selectIndex : t];
			a.some((r, n) => {
				if (r.value === l.speed)
					return (
						(i = 'PREV' === e ? n - 1 : 'NEXT' === e ? n + 1 : n),
						(s = a[i]),
						!s ||
							(i
								? i === a.length - 1
									? $('.ws-record-speed-add', this.$el).css({ cursor: 'not-allowed' })
									: ($('.ws-record-speed-sub', this.$el).css({ cursor: 'pointer' }), $('.ws-record-speed-add', this.$el).css({ cursor: 'pointer' }))
								: $('.ws-record-speed-sub', this.$el).css({ cursor: 'not-allowed' }),
							$('.ws-record-speed-txt', this.$el).text(s.label),
							'playing' === l.status && this.playSpeed(s.value, t),
							!0)
					);
			});
		}
		__addRecordControl() {
			this.$el.append(
				'\n            <div class="ws-control ws-record-control">\n                <div class="ws-timeline">\n                    <div class="ws-timeline-group"></div>\n                    <div class="ws-timeline-group"></div>\n                </div>\n                \x3c!--当前播放的时间点--\x3e\n                <div id="ws-record-time-box">\n                    <div class=\'ws-record-time\'>\n                        <span></span>\n                    </div>\n                </div>\n                <canvas height="60" id="ws-record-canvas" class="ws-record-area"/>\n            </div>\n        '
			),
				(this.canvas = document.getElementById('ws-record-canvas')),
				(this.ctx = this.canvas.getContext('2d'));
			let e = $(this.$el[0].getElementsByClassName('ws-timeline-group')[0], this.$el),
				t = $(this.$el[0].getElementsByClassName('ws-timeline-group')[1], this.$el);
			new Array(49).fill(1).forEach((t, s) => {
				let i = 'ws-time-space ' + (s % 4 ? '' : 'ws-time-space-long');
				e.append(`<span class="${i}"></span>`);
			}),
				new Array(13).fill(1).forEach((e, s) => {
					t.append(`<span class="ws-time-point">${(2 * s + ':00').padStart(5, '0')}</span>`);
				}),
				$('.ws-record-control', this.$el).mouseenter((e) => {
					$('.ws-record-control').append("<div id='ws-cursor'><div class='ws-cursor-time'><span></span></div></div>");
				}),
				$('.ws-record-control', this.$el).mousemove((e) => {
					let t = $('.ws-record-control', this.$el).width(),
						s = e.clientX - $('.ws-record-control', this.$el)[0].getBoundingClientRect().left,
						i = new Date(1e3 * ((s / t) * 24 * 60 * 60 - 28800)),
						a = `${`${i.getHours()}`.padStart(2, '0')}:${`${i.getMinutes()}`.padStart(2, '0')}:${`${i.getSeconds()}`.padStart(2, '0')}`;
					$('#ws-cursor', this.$el).css('left', s), $('#ws-cursor span', this.$el).text(a);
				}),
				$('.ws-record-control', this.$el).mouseleave((e) => {
					$('#ws-cursor', this.$el).remove();
				}),
				$('.ws-record-control', this.$el).click((e) => {
					if (['playing', 'pause'].includes((this.playerList[this.selectIndex] || {}).status)) {
						let t = $('.ws-record-control', this.$el).width(),
							s = e.clientX - $('.ws-record-control', this.$el)[0].getBoundingClientRect().left,
							i = parseInt((s / t) * 24 * 60 * 60, 10);
						this.clickRecordTimeLine(i);
					}
				});
		}
		__setTimeRecordArea(e = []) {
			if (e.length) {
				let t = $('.ws-record-control', this.$el).width();
				this.canvas.width = t;
				let s = [],
					i = [],
					a = this.ctx.createLinearGradient(0, 0, 0, 60);
				a.addColorStop(0, 'rgba(77, 201, 233, 0.1)'), a.addColorStop(1, '#1c79f4');
				let l = this.ctx.createLinearGradient(0, 0, 0, 60);
				l.addColorStop(0, 'rgba(251, 121, 101, 0.1)'),
					l.addColorStop(1, '#b52c2c'),
					e.forEach((e) => {
						e.width = ((e.endTime - e.startTime) * t) / 86400;
						let a = new Date(1e3 * e.startTime),
							l = a.getHours(),
							r = a.getMinutes(),
							n = a.getSeconds();
						(e.left = ((3600 * l + 60 * r + n) / 86400) * t), e.isImportant ? i.push(e) : s.push(e);
					}),
					s.forEach((e) => {
						this.ctx.clearRect(e.left, 0, e.width, 60), (this.ctx.fillStyle = a), this.ctx.fillRect(e.left, 0, e.width, 60);
					}),
					i.forEach((e) => {
						this.ctx.clearRect(e.left, 0, e.width, 60), (this.ctx.fillStyle = l), this.ctx.fillRect(e.left, 0, e.width, 60);
					});
			} else this.canvas.width = 0;
		}
		__setPlayingTime(e, t, s, i, a, l, r) {
			if (this.selectIndex === e) {
				let e = ((3600 * a + 60 * l + r) / 86400) * $('.ws-record-control').width(),
					t = `${String(a).padStart(2, '0')}:${String(l).padStart(2, '0')}:${String(r).padStart(2, '0')}`;
				$('#ws-record-time-box', this.$el).css('left', e), $('#ws-record-time-box span', this.$el).text(t);
			}
		}
		autoSetWSUrl(e, t) {
			return new Promise((s, i) => {
				e = e.map((e) => t + '://' + e);
				let a = 0,
					l = (t) => {
						let r,
							n = new WebSocket(t),
							o = !1;
						(n.onopen = () => {
							(o = !0), clearTimeout(r), n.close(), s(e[a - 1]);
						}),
							(n.onerror = () => {
								clearTimeout(r),
									(o = !1),
									a >= e.length ? i({ code: -105, message: '自动识别失败，存在端口为非默认端口，开始通过参数判断，请注意传参！' }) : l(e[a++]);
							}),
							(r = setTimeout(() => {
								!o && n.close();
							}, 1e3 * this.WS_TIMEOUT));
					};
				l(e[a++]);
			});
		}
		__getWSUrl(e) {
			let { rtspURL: s, streamServerIp: i, wsList: a, playType: l, wssDirect: r, talkData: n } = e;
			return new Promise((e, o) => {
				if ('url' === l) return void e();
				if (this.setWSUrl) return void e(this.setWSUrl(a));
				let d = this.wsProtocol || (this.isHttps ? 'wss' : 'ws');
				if (this.isHttps && (this.config.useNginxProxy || 0 === r || n)) {
					let a = s.match(/\d{1,3}(\.\d{1,3}){3}/g)[0];
					a || (a = s.split('//')[1].split(':')[0]);
					let l = 'real' === this.type ? t.websocketPorts.realmonitor : t.websocketPorts.playback;
					e(`${d}://${this.proxyServerIp}/${l}?serverIp=${this.streamServerIp || i || a}`);
				} else
					this.autoSetWSUrl(a, d, r)
						.then((t) => {
							e(t);
						})
						.catch((s) => {
							console.warn(s.message);
							let i = '';
							if (this.intranetMap) for (let e in this.intranetMap) e.includes(this.streamServerIp) && (i = this.intranetMap[e]);
							if (!i) return console.warn('请根据不同大华平台场景进行传参播放视频画面！！详情可查阅文档-快速入门'), void o();
							if (i.includes(':')) return void e(`${d}://${i}`);
							let a = '';
							(a =
								'wss' === d
									? 'real' === this.type
										? t.websocketPorts.realmonitor_wss
										: t.websocketPorts.playback_wss
									: 'real' === this.type
										? t.websocketPorts.realmonitor_ws
										: t.websocketPorts.playback_ws),
								e(`${d}://${this.streamServerIp}:${a}`);
						});
			});
		}
		__updatePlayerWindow() {
			setTimeout(() => {
				this.playerList.forEach((e) => {
					e.updateAdapter(this.playerAdapter);
				}),
					this.setTimeLine(this.timeList);
			}, 24),
				this.__updateTopBarStyle(),
				this.__renderDefaultStats();
		}
		__renderDefaultStats() {
			setTimeout(() => {
				this.playerList.forEach((e) => {
					e.renderDefaultStats();
				});
			}, 24);
		}
		__updateTopBarStyle() {
			setTimeout(() => {
				this.playerList.forEach((e) => {
					e.updateTopBarStyle();
				});
			}, 24);
		}
		__startTalk(e) {
			this.procedure && this.procedure.startTalk(e);
		}
		talkByUrl(e) {
			this.playerList[e.selectIndex].talkByUrl(e);
		}
		playRealVideo(e) {
			let { channelList: t = [], streamType: s = '2', windowIndex: i } = e;
			this.procedure && this.procedure.playRealVideo(t, s, i);
		}
		realByUrl(e) {
			this.playReal({
				playType: 'url',
				rtspURL: e.rtspURL,
				wsURL: e.wsURL,
				channelId: e.channelId,
				streamType: e.streamType,
				streamServerIp: e.streamServerIp,
				playerAdapter: e.playerAdapter,
				selectIndex: e.selectIndex,
				channelData: e.channelData || {},
			});
		}
		changeStreamType(e, t, s) {
			this.procedure && this.procedure.playRealVideo([e], t, s);
		}
		playRecordVideo(e) {
			this.procedure && this.procedure.getRecordList(e);
		}
		recordByUrl(e) {
			this.playRecord({
				playType: 'url',
				wsURL: e.wsURL,
				rtspURL: e.rtspURL,
				records: e.records || [],
				channelId: e.channelId,
				startTime: e.startTime,
				endTime: e.endTime,
				playerAdapter: e.playerAdapter,
				selectIndex: e.selectIndex,
				channelData: e.channelData || {},
			});
		}
		clickRecordTimeLine(e) {
			let t = new Date(1e3 * this.timeList[0].startTime).setHours(0, 0, 0) / 1e3 + e;
			this.timeList.some((s) => {
				if (t >= s.startTime && t < s.endTime) {
					let i = this.playerList[this.selectIndex];
					if (i.options.playRecordByTime && i.options.ssId === s.ssId) {
						let t = new Date(1e3 * i.options.startTime),
							s = t.getHours(),
							a = t.getMinutes(),
							l = t.getSeconds();
						i.playSDK.SetSeekTime(e - 60 * s * 60 - 60 * a - l);
					} else {
						if ('url' === i.playType) return void this.sendMessage('switchStartTime', { time: t, channelData: i.options.channelData });
						this.procedure && this.procedure.clickRecordTimeLine(e, s.ssId);
					}
					return !0;
				}
			}) || console.warn('所选时间点无录像');
		}
		jumpPlayByTime(e, t) {
			if ('real' === this.type) return void this.sendErrorMessage(613, { method: 'jumpPlayByTime', arguments: { time: e, selectIndex: t } });
			let s = this.playerList[void 0 === t ? this.selectIndex : t];
			if (!s) return void this.sendErrorMessage(601, { method: 'jumpPlayByTime', arguments: { time: e, selectIndex: t } });
			if (!['playing', 'pause'].includes(s.status)) return;
			let i = e.split(':'),
				a = 60 * (i[0] || 0) * 60 + 60 * (i[1] || 0) + 1 * (i[2] || 0);
			3 !== i.length || (!a && 0 !== a) || a >= 86400
				? this.sendErrorMessage(605, { method: 'jumpPlayByTime', arguments: { time: e } })
				: this.clickRecordTimeLine(a);
		}
		playNextRecord(e, t) {
			this.procedure && this.procedure.playNextRecord(e, t);
		}
		videoClosed(e, t, s) {
			this.sendMessage('closeVideo', { selectIndex: e, changeVideoFlag: t, channelData: s }), this.procedure && this.procedure.videoClosed(e, t, s);
		}
		sendErrorMessage(e, s = {}) {
			let i = t.errorInfo[e];
			s.insert &&
				(s.insert.forEach((e, t) => {
					i = i.replace(`$${t}`, e);
				}),
				delete s.insert),
				this.sendMessage('errorInfo', { errorCode: e, errorInfo: i, errorData: s });
		}
		startLocalRecord(e, t, s, i) {
			let a = this.playerList[void 0 === e ? this.selectIndex : e];
			a
				? 'playing' === a.status || 'pause' === a.status
					? a.isRecording
						? this.sendErrorMessage(602, { method: 'startLocalRecord', arguments: { selectIndex: e, name: t, size: s } })
						: ((a.isRecording = !0), a.startRecord(t, s, i), $('.record-icon', a.$el).addClass('recording'))
					: this.sendErrorMessage(603, { method: 'startLocalRecord', arguments: { selectIndex: e, name: t, size: s } })
				: this.sendErrorMessage(601, { method: 'startLocalRecord', arguments: { selectIndex: e, name: t, size: s } });
		}
		stopLocalRecord(e) {
			let t = this.playerList[void 0 === e ? this.selectIndex : e];
			t
				? t.isRecording
					? ((t.isRecording = !1), t.playSDK.StopRecord(), $('.record-icon', t.$el).removeClass('recording'))
					: this.sendErrorMessage(604, { method: 'stopLocalRecord', arguments: { selectIndex: e } })
				: this.sendErrorMessage(601, { method: 'stopLocalRecord', arguments: { selectIndex: e } });
		}
		setIvs(e, t, s) {
			let i = this.playerList[void 0 === t ? this.selectIndex : t];
			i
				? (i.playSDK.OpenIVS(),
					e
						? (s.includes(1) || i.playSDK.SetIvsEnable(3, 0), s.includes(2) || (i.playSDK.SetIvsEnable(1, 0), i.playSDK.SetIvsEnable(14, 0)))
						: i.playSDK.CloseIVS())
				: this.sendErrorMessage(601, { method: 'setIvs', arguments: { showIvs: e, selectIndex: t, ivsType: s } });
		}
		initPanTilt(e) {
			this.panTilt = new x({ ...e, prefixUrl: this.prefixUrl }, this);
		}
		setPtzChannel(e) {
			this.panTilt && this.panTilt.setChannel(e);
		}
		stopTalk(e) {
			this.procedure && this.procedure.stopTalk({ data: e });
		}
	}
	__publicField(Y, 'version', '1.3.0'),
		(e.WSPlayer = Y),
		(e.default = Y),
		Object.defineProperties(e, { __esModule: { value: !0 }, [Symbol.toStringTag]: { value: 'Module' } });
});
